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 trialamyp
6,574 PointsModify this object so it uses two properties firstName and lastName and remove their variable declarations from the full
Modify this object so it uses two properties firstName and lastName and remove their variable declarations from the fullName method. Don't do anything to the console.log() call right now.
var contact = {
firstName: "Andrew",
lastName: "Chalkey"
Console.log(firstName +" "+lastName);
}
4 Answers
Mariana Hoffmann
Courses Plus Student 11,046 Pointsgot it!
here's the code
part I
var contact = {
firstName: "Andrew",
lastName: "Chalkey",
fullName: function() {
console.log(firstName + " " + lastName);
}
}
part II
var contact = {
firstName: "Andrew",
lastName: "Chalkey",
fullName: function() {
console.log(this.firstName + " " + this.lastName);
}
}
Damian Hutter
16,742 Pointshey,
If you want to log these names into the console you have to call them on their variable first. Right now you try to call two variables with the name 'firstName' and 'lastName', but there are no such variables. try to call the object variable first 'contact' followed by the dataname 'firstName'
e.g contact.firstName
Mariana Hoffmann
Courses Plus Student 11,046 Pointshello, i'm stuck on the same challenge. i've already tried what you said up ahead, but it gets a parse error
here's the code:
var contact = {
fullName: {
contact.firstName = "Andrew";
contact.lastName = "Chalkley";
console.log(firstName + " " + lastName);
}
}
Damian Hutter
16,742 Pointsshould be, because you need to call the data in this way, not assign it this way. So it should be like:
var contact = { firstName: "Andrew", lastName: "Chalkey" Console.log(contact.firstName +" "+ contact.lastName); }
hope this helps you out
Mariana Hoffmann
Courses Plus Student 11,046 Pointsit didn't work out :/ thank you anyway
Damian Hutter
16,742 Pointstrue, haven't missed the .this in the description. Nice job