Question: Write a JavaScript function that takes an array of objects. Each object indicates a single person's information. Function name should be test(). Sample: test([ {name:'John',age:11},{name:'Tom',age:12},{name:'Mira',age:41},
Write a JavaScript function that takes an array of objects. Each object indicates a single person's information. Function name should be test().
Sample:
test([
{name:'John',age:11},{name:'Tom',age:12},{name:'Mira',age:41},
])
Output:
It will return an object from a function. That object will have two lists- Young and Old. Young will have elements with age 10-30 and Old will have elements with age 31-50. Each array will be sort by even ages people.
Sample Output:
{Young:[{name:'John',age:11},{name:'Tom',age:12}],
Old:[{name:'Mira',age:41}]
}
Please solve the coding problem immediately.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
