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

Thursday, December 6, 2012

Codecademy: Codeyear Yes! More recursion!


//sample solution


var change = 0;
function howManyQuarters(howMuchMoney) {
    //fill this in
    if(howMuchMoney<0.25){
change = howMuchMoney;
return 0;
    } else {
return 1 + howManyQuarters(howMuchMoney-0.25);
    }
}
change = 0.99;
console.log ("Pay out " + howManyQuarters(change) + " quarters");
console.log ("And you'll have " + change * 100 + " pennies left over");

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts