Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

flatMap

const arr4 = [1, 2, [3, [4, 5, [6, 7]]]] ;

console.log(arr4.flatMap((element) => element).flat(2)) ;

// expected output 
[1, 2, 3, 4, 5, 6, 7]
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #flatMap
ADD COMMENT
Topic
Name
5+2 =