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 trialMUZ140989 Eukael Mbuyisa
6,395 PointsModify this object so it uses two properties firstName and lastName and remove their variable declarations from the full
it keeps saying the code should be a string.....dnt knw where am gng wrong
var contact = {
//make firstName and lastName properties like this
property1: "value",
property2: "value",
fullName: function() {
//remove the var declarations from this method
//var firstName = "Andrew";
//var lastName = "Chalkley";
console.log(firstName + " " + lastName);
}
}
1 Answer
Kelly von Borstel
28,880 PointsHi, Eukael. You're off to a good start by commenting out the variable declarations inside the fullName function — they can be removed from the function. Next, you need to add them as properties to the contact object. Instead of property1: "value" and property2: "value", you want to add properties for firstName and lastName and assign the same strings that were used inside the fullName function. Here's the code — replace the question marks with the proper string values.
var contact = {
firstName: "???",
lastName: "???",
fullName: function() {
console.log(firstName + " " + lastName);
}
}