[Solved] JavaScript. forEach return an undefined


You need .some to check if any items in an array pass a test. forEach returns undefined:

const data = [
 {prop1: false, prop2: 'someValue'},
 {prop1: true, prop2: 'someValue'},
 {prop1: false, prop2: 'someValue'}
]

const isSomeProp1EqualToTrue = data.some(({ prop1 }) => prop1 === true);
console.log(isSomeProp1EqualToTrue);

4

solved JavaScript. forEach return an undefined