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

Thursday, December 6, 2012

Codecademy: Codeyear Fiddly Bits of Dot Notation


//sample solution


// Here is our person object
    var person = {
        //giggle
        //returns: 'giggle'
        giggle: function(){
            return "giggle";
        },
        //giggles
        //parameters: n - number of giggles
        //returns: string of giggles of n giggles long
        giggles: function(n){
            if (n>1)
                return this.giggle() + " " + this.giggles(n-1);
            if (n===1)
                return this.giggle();
        },
       
        fiveGiggles: function(){
            return this.giggles(5);
        }
    };
    console.log(person.fiveGiggles());

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts