Leetcode Geniuses please explain

https://leetcode.com/problems/kids-with-the-greatest-number-of-candies THIS WORKS, OK?
function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {
let max = Math.max(...candies);
return candies.map((kid) => kid + extraCandies >= max)
};
function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {
let max = Math.max(...candies);
return candies.map((kid) => kid + extraCandies >= max)
};
SOMEHOW THIS DOESN'T WORK WTF!!?
function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {
let result = []
let max = Math.max(...candies);
for (const kid in candies) {
result.push((kid + extraCandies) >= max)
}
return result
};
function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {
let result = []
let max = Math.max(...candies);
for (const kid in candies) {
result.push((kid + extraCandies) >= max)
}
return result
};
YET THIS WORKS???
function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {
let result = []
let max = Math.max(...candies);
for (let j = 0; j < candies.length; j++) {
result.push((candies[j] + extraCandies) >= max)
}
return result
};
function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {
let result = []
let max = Math.max(...candies);
for (let j = 0; j < candies.length; j++) {
result.push((candies[j] + extraCandies) >= max)
}
return result
};
1 Reply
barry
barryOP12mo ago
ok const x in is not the way its const x of kill me please
Want results from more Discord servers?
Add your server