Can someone give me some insight as to why the first 2 functions return undefined instead of a boolean?
https://jsfiddle.net/wjf2gr9d/
const array1 = [1, 2, 3];
const test1Result = test1();
const test2Result = test2();
const test3Result = test3();
console.log(test1Result);
console.log(test2Result);
console.log(test3Result);
function test1() {
return array1.forEach(x => 2 === x);
}
function test2() {
const found = array1.forEach((x, index) => {
if (2 === x) {
return true;
}
return false;
});
return found;
}
function test3() {
const maybeTeam = array1.find(x => 2 == x);
return (maybeTeam) ? true : false;
}
