LearnFrenzy
Sign in Take a free test

Arrays · Find the Error · Question 1

Error: missing comma in an array literal 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 prices = [120, 250 399, 75];
console.log(prices.length);
  • A It prints 3
  • B SyntaxError: elements must be separated by commas – 250 399 is invalid Correct
  • C It prints 4
  • D It treats 250399 as one number
Correct Answer: Option B

Two number literals next to each other are not valid syntax. Add the missing comma: [120, 250, 399, 75].

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