【发布时间】:2020-05-13 21:48:31
【问题描述】:
我想获取特定对象的百分比,例如: 我有一个选项数组:-
options: Array(2)
0: {id: 1, choice: "Yes", answer_count: 1}
1: {id: 2, choice: "No", answer_count: 0}
或 mcq 数组:-
options: Array(4)
0: {id: 1, choice: "Yes, of course", answer_count: 0}
1: {id: 2, choice: "There is not an immediate need in the product, I a…d it to get a basic understanding of the subject.", answer_count: 1}
2: {id: 3, choice: "This will help me to pursue my learning goal.", answer_count: 0}
3: {id: 4, choice: "No, I am not sure if it was helpful enough", answer_count: 0}
我需要从answer_count key 的总数中获取choice key 的百分比
喜欢:choice: "Yes, ofcourse" 与 answer count of choice: "Yes, ofcourse" to the total of all answer count in options 的百分比
谁能帮我解决这个问题
【问题讨论】:
标签: arrays typescript angular6 javascript-objects percentage