Create a function that gets the total amount and percentage of covid case data for each Age Group in the covid cases data set(which contains the property "Age Group" in each case array). Age Groups: 'younger than 18', 'between 19 to 28 Years', 'between 29 to 38 Years', 'between 39 to 48 Years', 'between 49 to 58 Years', 'between 59 to 68 Years', 'between 69 to 78 Years', 'between 79 to 88 Years', and 'older than 89' The function getSummaryOfAges(data) should return an Object with the following structure: { 'UnknownAge': { totalAmount: 27, percentageOfTotal: 0.001 }, 'younger than 18': { totalAmount: 39, percentageOfTotal: 0.074 }, 'between 19 to 28 Years': { totalAmount: 68 percentageOfTotal: 0.124 }, 'between 29 to 38 Years': { totalAmount: 59, percentageOfTotal: 0.100 }, ...etc } For the covid case Objects that don't have an Age Group value(meaning it's null). Then these case Objects should be treated as the "UnknownAge" Age Group category For each age category, calculate the total number of covid cases(500 cases), the total for each age group, and finally the percentage of the total. Update: sample data that can be used Example of case object: Case = { { "Age Group": "20 to 29 Years", "Fitness": "ACTIVE", "Gender Person": "FEMALE", }, { "Age Group": "20 to 29 Years", "Fitness": "ACTIVE", "Gender Person": "FEMALE", }, { "Age Group": "20 to 29 Years", "Fitness": "ACTIVE", "Gender Person": "MALE", },
[Javascript - Question]
Create a function that gets the total amount and percentage of covid case data for each Age Group
in the covid cases data set(which contains the property "Age Group" in each case array).
Age Groups: 'younger than 18', 'between 19 to 28 Years', 'between 29 to 38 Years', 'between 39 to 48 Years', 'between 49 to 58 Years', 'between 59 to 68 Years', 'between 69 to 78 Years', 'between 79 to 88 Years', and 'older than 89'
The function getSummaryOfAges(data) should return an Object with the following structure:
{
'UnknownAge': {
totalAmount: 27,
percentageOfTotal: 0.001
},
'younger than 18': {
totalAmount: 39,
percentageOfTotal: 0.074
},
'between 19 to 28 Years': {
totalAmount: 68
percentageOfTotal: 0.124
},
'between 29 to 38 Years': {
totalAmount: 59,
percentageOfTotal: 0.100
},
...etc
}
For the covid case Objects that don't have an Age Group value(meaning it's null).
Then these case Objects should be treated as the "UnknownAge" Age Group category
For each age category, calculate the total number of covid cases(500 cases), the total for each age group,
and finally the percentage of the total.
Update: sample data that can be used
Example of case object:
Case = {
{
"Age Group": "20 to 29 Years",
"Fitness": "ACTIVE",
"Gender Person": "FEMALE",
},
{
"Age Group": "20 to 29 Years",
"Fitness": "ACTIVE",
"Gender Person": "FEMALE",
},
{
"Age Group": "20 to 29 Years",
"Fitness": "ACTIVE",
"Gender Person": "MALE",
},
Step by step
Solved in 2 steps