Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我刚刚构建了一个评估应用程序,这是保存的答案。
{"2":"E","4":"C","5":"A"}
我的意思是用户刚刚回答了数字 2、4 和 5。然后我想以这种格式解析每个回答
没有回答 乙 没有回答 C 一个 没有回答
任何想法如何解析它?
var obj = { "2": "E", "4": "C", "5": "A" }; for (var i = 1, size = 6; i <= size; i++) { console.log(i +'. '+ (obj[i] || 'Not answered')); }
http://jsfiddle.net/vrhTA/