How to count backwards based off what value is in argument?

I have this function

 function fizzbuzz(n){

}

and I want to be able to put any number in n and count backwards to 0 and console.log on the screen. I know that a for loop is required but I’m not exactly sure how to use it

Not a for, but a while.
While this number is more than zero, -1 to this number.

PD: well, if you need a for, Jesse has the asnwer

1 Like

This challenge explains in detail what you are trying to do:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/count-backwards-with-a-for-loop/

This is one option for using a for loop:

function fizzbuzz(n){
  for (var i = n; i > 0; i--) {
    console.log(i);
  }
}

fizzbuzz(5);

-J

1 Like