Quotes help make search much faster. Example: "Practice Makes Perfect"

Wednesday, December 5, 2012

Codecademy: Codeyear Counting Down With Recursion


//sample solution

function countDown(current) {
    // Recursive case
    if (current > 1) {
        console.log(current);
        countDown(current - 1);
    }
   
    // Base case
    if (current === 1){
        console.log(current);
    }
}

// We start the loop by calling the function.
countDown(5);

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts