Just solved steamroller,
however,
not fully understand the below situation:
arr = [1, {}, [3, [[4]]]]
console.log(arr.every(Array.isArray));//false
console.log(arr.every(!(Array.isArray)));//TypeError: false is not a function
Just solved steamroller,
however,
not fully understand the below situation:
arr = [1, {}, [3, [[4]]]]
console.log(arr.every(Array.isArray));//false
console.log(arr.every(!(Array.isArray)));//TypeError: false is not a function
.every
takes a function as an argument. Putting the ! out from coerces the function pointer into a boolean.
In my solution I used this:
arr.every(elem => (!Array.isArray(elem)))
I was trying to write it with less code, but this:
arr.every((!Array.isArray))
is also incorrect apparently.
It’s incorrect for the same reason. You need a function as the callback.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.