const data = [
{
question: "What is your choice of beverage ?",
type: LIST,
options: ["Tea", "Coffee", "Soft drinks", "Water"],
responses: ["Coffee", "Coffee", "Tea", "Soft drinks", "Coffee", "Coffee", "Water"]
},
{
question: "What is your favourite travel destination ?",
type: MCQ,
options: ["England", "Australia", "UAE", "Malaysia"],
responses: ["England" , "Norway", "England", "France", "England", "Malaysia", "UAE"]
},
{
question: "Which chocolates do you like ?",
type: CHECKBOX,
options: ["Dairy milk", "Five star", "Milky bar", "Munch", "KitKat"],
responses: [["Five star", "Milky bar", "Munch", "KitKat"],
["KitKat"],
["Five star", "Milky bar", "Munch", "KitKat"],
["KitKat"],
["Dairy milk"],
["Dairy milk"],
["Dairy milk", "KitKat"]
]
}
]
This is your input data
3 types of objects in data object
LIST, MCQ, CHECKBOX
For each you need to iterate the responses and create frequency maps corresponding to the options
and then print the map in console
For 1st object in data printed map will look like this
{
"Tea": 1,
"Coffee": 4,
"Soft drinks": 1,
"Water": 1
}