'How to use conditionals in While loop to replace numbers with strings? (JS)

The instructions of my challenge say this:

"Using a WHILE loop, write a function imAboutToExplodeWithExcitement which prints a countdown from n. When the countdown gets to 5, print 'Oh wow, I can't handle the anticipation!' When it's at 3, print 'I'm about to explode with excitement!' When the counter is finished, print 'That was kind of a let down'."

I have managed to solve the first part and print the string "That was kind of a let down" at the end of the countdown.

My issue is that I do not know how to use if/else conditionals to replace the numbers at certain iterations with the strings (at numbers 3 and 5).

I know it involves using conditionals but I do not know what such a phrase would look like at all.

Thank you.

function imAboutToExplodeWithExcitement(n){
    //declare variable countdown 
    let countDown = n 
  // using a while loop, decrement from the value of n to 0
  while( countDown >= 0) {
    console.log(countDown); 
    countDown--;
    // if-else statements to replace 3 and 5 with their respective strings... 
    if 
    }
    
  
  //print message marking the end of the countdown 
    console.log("That was kind of a let down.");
}   

imAboutToExplodeWithExcitement(10); // expected log 10, 9, 8, 7, 6, 'Oh wow, I can't handle the anticipation!', 4, I'm about to explode with excitement!', 2, 1, 'That was kind of a let down'


Solution 1:[1]

I wrote this and it seems to work the way you want it! The output of this code prints the number 10 and goes all the way down to 0, but on numbers 5, 3, and 0, it replaces those numbers and prints out a specific string!

function imAboutToExplodeWithExcitement(n) {
  while (n >= 0) {
    if (n > 5) console.log(n)
    else if (n === 5) console.log(`Oh wow, I can't handle the anticipation!`)
    else if (n === 3) console.log(`I'm about to explode with excitement!`)
    else if (n === 0) console.log(`That was kind of a let down`)
    else if (n > 0) console.log(n)
    n--
  }
}

Solution 2:[2]

function imAboutToExplodeWithExcitement(n){
  while(n){
    if(n === 5){
     console.log("Oh wow, I can't handle the anticipation!"); 
    }else if(n === 3){
     console.log("I'm about to explode with excitement!"); 
    }else{
     console.log(n);
    }
    n--;
  }
    console.log('That was kind of a let down');
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 justwantedtohelp
Solution 2 Eddy Kaggia