I'm struggling a bit with higher-order functions. I want to compare two arrays to see if all the values of one array are part of another array. In that case I want to return true, otherwise false.
My code:
let arrayA = [4,5,6,7]
let arrayB = [4,5,6,7,8];
let result = arrayA.forEach(number => {
if (!arrayB.includes(number)){
return false
}
else {
return true
}
})
console.log(result) //=> undefined
Thanks for reading or even helping a beginner out!