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 trialBrody Ricketts
15,612 PointsAttempting to mimic the code for Objects Lesson.
I am attempting to mimic Jim's code on the Prototypes lesson part 1 and two.
I believe I have copied his code to the letter, however when I attempt to run this in Chrome the same fashion as Jim, it's giving me undefined errors for everything.
var personPrototype = {
name: 'Anonymous'
greet: function (name, mood) {
name = name || "You";
mood = mood || "good";
console.log("Hello, " + name +
"I am " + this.name +
" and I am in a " + mood + " mood!");
},
species: 'Homo Sapien'
}
function Person (name) {
this.name = name;
}
Person.prototype = personPrototype;
brody = new Person("Brody");
Brody Ricketts
15,612 PointsHayden, you should throw that in the answer section because that was the answer. Always the small syntax errors that get me.
Thank you very much
Hayden Taylor
5,076 PointsHayden Taylor
5,076 Pointsare you not missing , (comma) after the object property? for example: name: 'Anonymous', <-- comma