Javascript Recursive Function Count down to zero

Description

Javascript Recursive Function Count down to zero

function countDownToZero(n) {
    // base case. Stop at 0
    if (n <= -1) {
        return; // stop the function
    } else {/*w ww . j  a  va2 s.com*/
        console.log(n);
        countDownToZero(n - 1); // count down 1
    }
}
countDownToZero(12);



PreviousNext

Related