Untitled

Return the number of balls with a given color
mail@pastecode.io avatar
unknown
typescript
22 days ago
299 B
3
Indexable
Never
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;
}
Leave a Comment