Untitled

Return the number of balls with a given color
 avatar
unknown
typescript
a year ago
299 B
7
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