Birthday Cake Candles

  • + 0 comments

    Typescript:

    let candle_height = 0;
    let tallest_candle = 0;
    for (let i = 1; i < candles.length; i++) {
       if (candles[i] > tallest_candle) {
          tallest_candle = candles[i];
       }
    }
    for (let i = 0; i < candles.length; i++) {
       if(Number(tallest_candle) == Number(candles[i])){
          candle_height += 1;
       }
    }
    return candle_height;