Hi All, the below code is for birthday candle problem in hackerrank. It is working fine in visual studio code but throws error in hackerrank. if anyone knows what is the problem with the code let me know…
function birthdayCakeCandles(candles) {
let max = Math.max(...candles)
let count=0
for(let i=0;i<candles.length;i++){
if(candles[i]===max){
count++
}
}console.log(count)
}
birthdayCakeCandles([1,3,2,3])
output: The maximum height candles are of height "3 units". There are two of them, so 2 should be the output.
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.