Вы можете получить массив свойства answer_count с помощью:
choices.map(function(item) {
return item['answer_count']
})
Затем вы можете уменьшить этот массив, чтобы получить количество ответов, например:
choices.map(function(item) {return item['answer_count']}).reduce(function (a, b) {
return (a + b)
});
Наконец, просто получить процент, разделив answer_count на сумму и умножив результат на 100:
(item['answer_count'] / totalAnswers) * 100
Используя предоставленные вами данные:
let choices = [
{id: 1, choice: "Yes, of course", answer_count: 0},
{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},
{id: 3, choice: "This will help me to pursue my learning goal.", answer_count: 0},
{id: 4, choice: "No, I am not sure if it was helpful enough", answer_count: 0}
];
let totalAnswers = choices.map(function(item) {return item['answer_count']}).reduce(function (a, b) {
return (a + b)
});
let percentages = choices.map(function (item) {
return {
'id': item['id'],
'choice': item['choice'],
'percentage': (item['answer_count'] / totalAnswers) * 100
}
})
console.log(percentages);