Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
orange sky
Front End Web Development Techdegree Student 4,945 Pointsmy apply() is not working
Hello! I am not sure why my apply method (which I have commented our, to find another way to get this code to work) is not working here. Can you please help me.
Cheers!
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
var personPrototype =
{
name: 'Anonymous',
greet : function(name, mood){
name = name || 'you';
mood = mood || 'good';
console.log("hello" + name +
" I am " + this.name +
" am I am in a " + mood + "mood!");
}
};
function Person ( name ){
this.name = name;
}
Person.prototype = personPrototype;
Jim = new Person("jim");
//console.log(Jim.greet.apply(Jim, ['Rose', 'great']);
console.log(Jim.greet('Rose', 'great'));
</script>
</body>