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 Object-Oriented JavaScript (2015) Introduction to Methods Create an Object Literal

Sasha Ewan
Sasha Ewan
3,457 Points

Don't understand why I can't pass task 2 of this challenge

I'm supposed to assign my name to the fullName property, but when I submit it just keeps saying Task 1 is no longer passing. I don't know what the error is.

object.js
var contact = {
  fullName = "Stacy Wi";
};
Sasha Ewan
Sasha Ewan
3,457 Points

also in posting, my colon was somehow turned into an equal sign. The code i'm actually submitting is:

var contact = { fullName : "Stacy Will"; };

But it won't let me pass.

3 Answers

Josh Haywood
Josh Haywood
5,621 Points

You need to leave out the semicolon inside your object constructor. If you had more properties to define, you would use a comma, but the last property would not have any punctuation after except for the closing curly brace. You're looking for

var contact = { 
  fullName: "Stacy Wi" 
};
Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Sasha, The first part of the challenge wants you to create an object literal with no properties to the variable contact, which you did right. The 2nd part wants you to assign your name to the 'fullName' variable in the object literal. But since the object literal is empty, you need to assign the variable and the value together. So your code will look like this:

var contact = {};
contact.fullName = "Sasha";

Hopefully that makes sense to you. If not, please let the me know. Jason :)

Irfan Hussain
Irfan Hussain
Courses Plus Student 6,593 Points

Why did u repeat object its already assign.

fullName: "Sasha"

var contact = { fullName: "Ary de Oliveira" };