Kids With the Greatest Number of Candies LeetCode solution in JavaScript
1var kidsWithCandies = function (candies, extraCandies) {2//First find out maximum number in array:->3let max = 0,4res = [];5for (let i = 0; i < candies.length; i++) {6if (candies[i] > max) max = candies[i];7}8console.log(max);910/*Now add extraCandies with every element in array and checks if11that sum is equals to or greater than max and return true and false otherwise; */1213for (let i = 0; i < candies.length; i++) {14let temp = candies[i] + extraCandies;15if (temp >= max) res.push(true);16else res.push(false);17}18return res;19};