You are viewing a single comment's thread. Return to all comments →
You could even do this in a single line of code, like so:
function birthdayCakeCandles(ar) { return ar.filter(i => i === Math.max(...ar)).length; }
But I found that this causes recursion issues. This works perfectly fine though:
function birthdayCakeCandles(ar) { var max = Math.max(...ar); return ar.filter(i => i === max).length; }
Seems like cookies are disabled on this browser, please enable them to open this website
Birthday Cake Candles
You are viewing a single comment's thread. Return to all comments →
You could even do this in a single line of code, like so:
function birthdayCakeCandles(ar) {
return ar.filter(i => i === Math.max(...ar)).length;
}
But I found that this causes recursion issues. This works perfectly fine though:
function birthdayCakeCandles(ar) {
var max = Math.max(...ar);
return ar.filter(i => i === max).length;
}