vendredi 19 novembre 2021

getting SyntaxError: Invalid shorthand property initializer (This isn't spam and i don't have other people mistakes who posted the same question)

I just started learning js. And I run to this exception: SyntaxError: Invalid shorthand property initializer

This is my code:

const movie = {
    title: 'a',
    releaseYear = 2018,
    rating: 4.5,
    director: 'b'
};
showProperties(movie);

function showProperties(obj){
    for (let key in obj){
        if (typeof obj[key] === 'string')
            console.log(key, obj[key]);
    }
}

What is wrong with this code? I checked other people who got this error on their js code but i didn't have none of their mistakes.

What should I do?

Thanks.




Aucun commentaire:

Enregistrer un commentaire