【发布时间】:2018-08-03 06:36:34
【问题描述】:
const myQuestions = [
{
level:"Level 1",
questionNo: 1,
sentence: "Her uncles are army officers.",
question: "Q . Which words are about people? ",
answers: {
"1": "a. uncles / officers",
"2": "b. her/are",
"3": "c. in/the"
},
correctAnswer: "1",
topic: "Noun",
description: "plural nouns"
},
{
level:"Level 1",
questionNo: 2,
sentence: "He dropped the glass and it broke into many pieces.",
question: "Q . Which word stands for 'the glass'?",
answers: {
"1": "a. he",
"2": "b. it",
"3": "c. into"
},
correctAnswer: "2",
topic: "Pronoun",
description: "pronoun 'it' and what it has already referred to"
},
....
]
这是我的 JSON。下面是我的 Html5 代码
<div class="answers"> ${answers.join("")} </div>
现在我们也得到了这样的键和值。
1:一个。叔叔/军官
但我们只想要值。谁能解决这个问题?
【问题讨论】:
-
什么是
answers? -
你是如何从
myQuestions[i].answers创建answers的? -
使用
Object.values(myQuestions[i].answers)获取值。
标签: javascript json node.js html