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

Wednesday, December 5, 2012

Codecademy: Codeyear MF! Methods and Functions


//sample solution


var australia = {
    hemisphere: "southern",
    population: function(newArrivals) {
        return 20000000 + newArrivals;
    }
};

var australia2 = new Object();
australia2.hemisphere = "southern";
australia2.population = function(newArrivals){
    return 20000000 + newArrivals;
};

// create your objects and methods here
var me = {
planet: "Earth",
age: function(yearBorn){
var date = new Date();
var currentYear = date.getFullYear();
return currentYear - yearBorn;
}
};

var jeremyLin = new Object();
jeremyLin.team = "Knicks";
jeremyLin.playGame = function(opponent){
return "Tonight the Knicks square off against the "+opponent;
};
//test
console.log(me.planet);
console.log(me.age(2000));
console.log(jeremyLin.team);
console.log(jeremyLin.playGame("Lakers"));

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts