首页 > 解决方案 > 我的控制台显示 Uncaught SyntaxError: Unexpected identifier

问题描述

它显示在第四行

var questions =[{
    question: "Who was the King after God's heart?",
    Choices: ["Adam", "Solomon", "Daniel", "David"]
    correctAnswer: 3
}]

标签: javascript

解决方案


你只是忘了一个逗号

var questions =[{ question: "Who was the King after God's heart?", Choices: ["Adam", "Solomon", "Daniel", "David"], correctAnswer: 3 }]

var questions =[
   { 
      question: "Who was the King after God's heart?", 
      Choices: ["Adam", "Solomon", "Daniel", "David"], // this is the comma you forgot 
      correctAnswer: 3 
   }
 ]
 
 console.log(questions)


推荐阅读