Skip to content

1431. Kids with Greatest Number of Candies

Difficulty: EASY

Problem description can be found here

One learning point or “recap” for me was to use Math.max(...numArr) to easily find the max number in an array of numbers in JavaScript.

function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {
const currentMax = Math.max(...candies);
const output: boolean[] = [];
for (const candy of candies) {
if (candy + extraCandies >= currentMax) {
output.push(true);
} else {
output.push(false);
}
}
return output;
}