Skip to content

Commit 6bd9e13

Browse files
author
Jaskaran Singh
authored
Create greatest_number_of_candies.js
1 parent 5c5fb26 commit 6bd9e13

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

greatest_number_of_candies.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @param {number[]} candies
3+
* @param {number} extraCandies
4+
* @return {boolean[]}
5+
*/
6+
var kidsWithCandies = function(candies, extraCandies) {
7+
let result = [];
8+
9+
for(let i = 0; i < candies.length; i++) {
10+
if((candies[i] + extraCandies) >= Math.max(...candies))
11+
result.push(true);
12+
else
13+
result.push(false);
14+
}
15+
16+
return result;
17+
};

0 commit comments

Comments
 (0)