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 Introduction to Programming Objects and Arrays Objects

Blaine Fallis
Blaine Fallis
2,449 Points

When I try to use "Employee Number" as part of the object, I get an error: Uncaught SyntaxError: Unexpected string

re:

var me = {
    first_name: "Jim",
    last_name: "Hoskins"
    "Employee Number": 1
}

console.log(me.first_name);
console.log(me.last_name);
console.log(me["Employee Number"]);
console.log(me);
Blaine Fallis
Blaine Fallis
2,449 Points

whoops, there's no comma after Hoskins. I caught that after hitting submit :)

3 Answers

Goran Penov
Goran Penov
1,635 Points

I have the same error. Did you figure it out?

Goran Penov
Goran Penov
1,635 Points
var me = {
    first_name: "Goran",
    last_name: "Penov",
    "Employee Number": 1
}

console.log(me.first_name);
console.log(me.["last_name"]);
console.log(me["Employee Number"]);
console.log(me);

you have put (;) you need to put (,) after end of each.

Carlton Stith Jr.
Carlton Stith Jr.
9,077 Points
var me = {
    first_name: "Carlton",
    last_name: "Stith",
    "Employee Number": 1
}

console.log(me.first_name);
console.log(me["last_name"]);
console.log(me["Employee Number"]);
console.log(me);