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!

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 Multiple Items with Arrays Adding Items to an Array

what is the error; ReferenceError: Left side of assignment is not a reference.

i dont know what it means or whats wrong

var guestList = ['Sandra', 'Omar', 'Magnus', 'Becky'];
guestList.push() = ["Tony", "Geen",];
<!DOCTYPE html>
  <meta charset="utf-8">
  <title>JavaScript Loops</title>
<script src="script.js"></script>

ive tried changing the " " , 's into ' ' ,

Dehn Hunsworth
Dehn Hunsworth
7,189 Points

and there is an extra comma in the array your adding to original

2 Answers

Dehn Hunsworth
Dehn Hunsworth
7,189 Points

Its because of the = the array your adding to the guestList should be inside the ()

guestList.push(["name1", "name2"]);
Dehn Hunsworth
Dehn Hunsworth
7,189 Points

I believe not a reference is kinda like saying its not a variable, since its a method your calling on a variable.

Rewatch the previous video Adding Data to Arrays from about the 2:00 to about the 3:20 mark. The items you want to push to your array will go inside the parentheses of the push method. You also don't need to add the brackets.