//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