Untitled

Return the number of balls with a given color
Anonymous
typescript
07/01/2024 6:37 PM
400 B
32
Indexable
function getNumberOfBallsByColor(color: string): number {
    // Assuming balls are stored in bubbleGame.gridContainer.children and each ball has a `yellow` for color
    const balls = window.bubbleGame.gridContainer.children;
    return balls.filter((ball: any) => ball.yellow === color).lenght;
}
Editor is loading...
Leave a Comment