DHRUV KAUSHAL
DHRUV KAUSHAL

Reputation: 127

missing } after property list error in javascript

I am encountering the above mentioned error, I wonder why it is popping up. All my curly brackets are correct as far as I see. Given below is the code segment:

var mapped = data.map(d => {

    return {
        date: d.date;
        value: d.count;
    }
});

The console is pointing to this line:

date: d.date;

I wonder why this is popping up. Any help is appreciated. thanks!

Upvotes: 0

Views: 57

Answers (2)

Juhil Somaiya
Juhil Somaiya

Reputation: 953

Every objects can contains multiple attributes/properties and each must be separated with ,. Please adopt the following code and you'll be good to go.

var mapped = data.map(d => {
    return {
        date: d.date,
        value: d.count
    }
});

Upvotes: 1

Akash Shrivastava
Akash Shrivastava

Reputation: 1365

You have incorrectly used semicolon within objects.

The properties within an object should be separated using commas.

var data = [];

var mapped = data.map(d => {

    return {
        date: d.date, // here you used `;` instead of comma 
        value: d.count
    }
});

Upvotes: 3

Related Questions