Illustration:
{
Are you a coffee drinker?: yes,
Do you like to exercise regularly?: no,
How often do you eat out at restaurants?: 3 times a week,
What is your favorite type of cuisine?: Italian
}
Results:
{yes: 1, no: 1, 3 times a week: 1}
Expected results:
{1: "yes", 2: "no", 3: "3 times a week" , 4: "Italian"}
Function implemented:
getPreferences() {
this.preferenceCount = {};
for (let key in this.formAnswers) {
console.log(this.formAnswers)
if (! this.preferenceCount[this.formAnswers]) {
this.preferenceCount[this.formAnswers[key]] = (this.preferenceCount[key]+1) || 1
}
}
console.log(this.preferenceCount);
}