Adding properties; Contact List; 4/8


#1

https://www.codecademy.com/en/courses/javascript-beginner-en-3bmfN/0/4?curriculum_id=506324b3a7dffd00020bf661#


"Problem with syntax". Help pls. Thanks in advance


var friends = {
    bill:{
    firstName: "Bill",
    lastName: "Gates",
    number: "(206) 555-5555",
        },
    steve:{
    firstName: "Steve",
    lastName: "Jobs",
    number: "(206) 555-5555",
        },
    paddy:{
    firstName: "Paddy",
    lastName: "Alviar",
    number: "(661) 369-4157",
    };
};


#2

You don't need semicolons on the last to curly brackets. I would also suggest that you don't add an extra person until after you have completed the exercise.


#3

Noted. Thank you. I thought adding semicolons were mandatory after each line of code?


#4

Usually yes, but there are some cases where semicolons are not necessary and can mess up your code. I normally code in languages that don't have semicolons, but unfortunately when coding in Java Script then you don't have that luxury :slight_smile:.


#5

The only time we write a semi-colon after a curly brace is when it is a statement.

var myObj = {

};

var func = function () {

};

In both of the above there is an assignment. The right hand side of the equal sign is an expression.


#6

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