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 JavaScript Loops, Arrays and Objects Tracking Data Using Objects The Build an Object Challenge, Part 2 Solution

Immanuel Jaeggi
Immanuel Jaeggi
5,164 Points

Weird error in console

Hey fellow coders..there' a weird error that's showing up in the console, and without solving it I can't see if my answer to the challenge worked. Here's the code:

var students = [

{name: Thomas, track: iOS, achievements: 001, points: 20}, {name: Giselle, track: iOS, achievements: 002, points: 200}, {name: Sarah, track: Python, achievements: 003, points: 450}, {name: Matt, track: PHP, achievements: 004, points: 700}, {name: Lisa, track: Java, achievements: 005, points: 75}

];

Console says: Uncaught reference error: Thomas is not defined

I keep changing the name but I know that's not the problem. Anyone?

2 Answers

Adam Pengh
Adam Pengh
29,881 Points

You're trying to use Thomas as a string, so you need either single or double quotes. Since there are not quotes, the browser is interpreting it as a variable.

var students = [
  {
    name: 'Thomas',
    track: 'iOS',
    achievements: 001,
    points: 20
  }, 
  {
    name: 'Giselle',
    track: 'iOS',
    achievements: 002,
    points: 200
  }, 
  {
    name: 'Sarah',
    track: 'Python',
    achievements: 003,
    points: 450
  }, 
  {
    name: 'Matt',
    track: 'PHP',
    achievements: 004,
    points: 700
  }, 
  {
    name: 'Lisa',
    track: 'Java',
    achievements: 005,
    points: 75
  }
];