1function double(arr) {
2 return arr.forEach(num => num*2);
3}
4
5console.log(double([1,2,3,4])) //undefined
6
1const list = [{ name: "John", age: 36 },{ name: "Jack", age: 17 }];
2
3// if you just have to FIND an object with a specific value,
4// use Array.prototype.find:
5const foundHim = list.find( person => person.name === "John" );
6console.log( foundHim );
7
8// if you still want to / need to RETURN the object / value
9let returnedHim;
10list.forEach( person => {
11 if ( person.age === 17 ) {
12 returnedHim = person;
13 }
14});
15
16console.log( returnedHim )