I have the code below. I am purposefully trying to use forEach in this instance.
function check(arr, el) {
arr.forEach((element) => {
console.log(element)
if (element === el) {
return true
}
})
}
check([1, 2, 3, 4, 5], 3)
I am expecting the code to return true because the el value of 3 is in the array. But instead it returns undefined. What am I doing wrong?