Codecademy Project FizzBuzz++ The Method Answer

The Function Project FizzBuzz++: The Return of Modulus from Codecademy. Answered by Michael Le.

1.2 Functions: Data Provided / Taken

/*
Michael Le
Codecademy username: mikele
Javascript Function Project: FizzBuzz++: The Return of Modulus
1.2 The Method: Functions: Data Provided / Taken
*/

// 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());

1.7 One More Function

/*
Michael Le
Codecademy username: mikele
Javascript Function Project: FizzBuzz++: The Return of Modulus
1.7 The Method: One More Function
*/

var comedy = {
    
    irony:function(){
        alert("hello");
    },
    
    schadenfreude:function(){
        alert("goodbye");
    },
    
    slapstick:function(n){
        if(n=="Murdoch"||n=="Gates")
            return "Pie!";
        else if(n == "Hollande")
            return "Flour";
        else
            return "Make Up!";
    }
};

//Run each function
comedy.irony();
comedy.schadenfreude();
comedy.slapstick("Gates");