Skip to Main Content

Kids With the Greatest Number of Candies

Problem URL:Kids With the Greatest Number of Candies

My Solution

JavaScript / TypeScript

const kidsWithCandies = (
  candies: number[],
  extraCandies: number
): boolean[] => {
  let maxCandies: number = Math.max(...candies),
    result: boolean[] = [];

  for (let candy of candies) {
    result.push(candy + extraCandies >= maxCandies);
  }

  return result;
};

Let's Connect

Twitter GitHub LinkedIn