LearnFrenzy
Sign in Take a free test

Objects · Find the Error · Question 1

Error: missing comma between properties Answer, explanation & discussion

  • Find the error
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 1 Back to Exercise

JavaScript refuses to run the code below. Which statement correctly describes the problem?

main.js
const user = {
  name: "Asha"
  age: 21,
};
console.log(user.age);
  • A SyntaxError: properties must be separated by commas – a comma is missing after "Asha" Correct
  • B It prints 21
  • C It prints undefined
  • D ASI inserts the missing comma
Correct Answer: Option A

Automatic semicolon insertion never inserts commas. Inside an object literal every property except the last needs a comma after it.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links