-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforEach practice.js
More file actions
38 lines (31 loc) · 885 Bytes
/
forEach practice.js
File metadata and controls
38 lines (31 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//filter these objects and find if they are underage or not
const ppl = [
{name: 'Alan', age: 26},
{name: 'David', age: 16},
{name: 'John', age: 46},
{name: 'Sarah', age: 32},
{name: 'Emily', age: 19},
{name: 'Michael', age: 41},
{name: 'Jessica', age: 15},
{name: 'Robert', age: 38},
{name: 'Ashley', age: 24},
{name: 'Christopher', age: 29},
{name: 'Amanda', age: 17},
{name: 'Matthew', age: 35},
{name: 'Brittany', age: 22},
{name: 'Joshua', age: 44},
{name: 'Samantha', age: 18},
];
const uwu=(ppl)=>{
let underage=[];
let adult=[];
ppl.forEach(person => {
if (person.age>=18){
adult.push(person.name);}
else{
underage.push(person.name)
}
});
console.log(`${adult} are adults and can drink.\n`)
console.log(`the underage people are ${underage}`)}
uwu(ppl);