Recursion in javascript: function loop


#1

Hi can anyone see what is wrong with this code?

          function countTo(int) {

         for (var i = 1; i<=int; i++){
         console.log(i);

         }

        countTo(5);
        }

it just responds with failed.


#2

the function call:

countTo(5);

should be after your function:

 function countTo(int) {

         for (var i = 1; i<=int; i++){
         console.log(i);

         }
  // function call shouldn't be here
} // closes the function
// it should be here, after your function

see comments i made in the code above


#3

thank you! It now works!


#4