6/6 Unexpected token "["


Hi! When I run the code, I get,"SyntaxError: Unexpected token [".
Can somebody please help me out? Thank you so much!
Here is my code:

var add = function(firstName, lastName, email, phoneNumber){
var contacts[contacts.length] = {
firstName: firstName,
lastName: lastName,
email: email,
phoneNumber: phoneNumber
add("Angelika", "Trump", "fake@email.com.edu", "62226251");

Thank you once again!


Hey @dragonwizard22! I dont know why you added contact.length but your not suppose to.. Its not the correct syntax so just delete this piece of code from your code()


Hope this helped!


Hi! When I delete the contacts.length, my new contact will not be added and the result will be:
Bob Jones
Mary Johnson

Isn't the contacts.length required to ensure that the new contact will be added at the back of the array?


You can just use it like an Object way like i did:

    var Amanuel = new Object();
    Amanuel.firstName = firstName;
    Amanuel.lastName = lastName;
    Amanuel.email = email;
   contacts[2] = Amanuel;

in the Add function then just call it like this:

add("Amanuel" , "Bogale" , "abogale2@gmail.com" , 44323132412);

Hope this helped!


Hmmm... I'm sorry. I did that and still got the same result. :confused:


del "var" in the piece of code "var contacts[contacts.length]" :wink: