SyntaxError: Unexpected identifier


#1

https://www.codecademy.com/courses/javascript-beginner-en-9Sgpi/3/1?curriculum_id=506324b3a7dffd00020bf661#

When I typed this up, all it said was SyntaxError: Unexpected identifier. So I tried changing around the variables in the object, which still did nothing. Then I tried changing the boolean, which also did nothing. I can't figure out what the unexpected identifier is.

var myObj = {
    type: 'third'
    randomthing: 'banana'
};

var myArray = [ 3, true, "gene", myObj ] ;


#2

HI in your object you should separate each key/value with a comma like that

var myObj = {
    type: 'third' , <-- #add on comma here
    randomthing: 'banana'
};

#3

var myObj = {
type: 'third'
randomthing: 'banana'
};

var myArray = [ 3, true, "gene", myObj ] ;

corrected code:
var myObj = {
type: 'third',
randomthing: 'banana'
};

var myArray = [ 3, true, "gene", myObj ] ;

you forgot comma before secnod key of myObj.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.