According to the Mozilla Developer Website:
The flatMap() method first maps each element using a mapping function, then flattens the result into a new array. It is identical to a map followed by a flat of depth 1, but flatMap is often quite useful, as merging both into one method is slightly more efficient.
Example:
let arr = [1, 2, 4, 2, 3, 3, 4, 5, 5, 5, 8, 8, 9, 10];
const flatMap = arr.flatMap(x => x);
console.log(flatMap);
TypeError: arr.flatMap() is not a function
Why is this returning this error?
EDIT
I am running this through Atom text editor and have used HomeBrew to update it to the latest version using brew upgrade node
and it is still giving me the same error.
I have also tried npm install n -g
flatMap
on that array? – Expert