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

JavaScript JavaScript Foundations Objects Call and Apply

R D
R D
228 Points

Issue with answer

I solved the problem correctly but system is not showing me that. My answer is greeting.apply(andrew, args1) at line 30. Please advise what I am doing wrong. Thanks, Raman

3 Answers

Hi R D,

Can't tell you what you're doing wrong without seeing the code.

Jeff

R D
R D
228 Points

Hi Jeff,

Below is the code:

var genericGreet = function(name, mood) { name = name || "you"; mood = mood || "good"; return "Hello " + name + ", my name is " + this.name + " and I am in a " + mood + " mood!"; };

  var andrew = {
    name: "Andrew"
  };

  var args1 = ["Michael", "awesome"];

  var greeting = genericGreet;
  greeting.apply(andrew, args1);

If I do "greeting.apply(andrew, args1)" in the console then I got the below output but not in the browser. "Hello Michael, my name is Andrew and I am in a awesome mood!"

I believe this is what they're looking for.

var greeting = genericGreet.apply(andrew,args1);