The birthdayCakeCandles() function creates a list of numbers and assigns it to the variable number_candles. The function then loop through the list of candles and checks to see if the candle's number is equal to the max candle number. If the number is equal to the max candle number, the function increases the number_candles variable by one.

    function birthdayCakeCandles(candles) {
      var max_candles = Math.max(...candles) 
      var number_candles = 0
      for(var i=0; i<candles.length; i++){
        if(candles[i] == max_candles){
          number_candles = number_candles + 1   
      return number_candles;
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.