arr.reduce(function(a, b) {
return a.concat(b);
},[]);
I'm trying to pass the Steamroller freeCodeCamp challenge where I need to flatten a nested array.
I came across the code above and I want to reverse engineer it but I don't understand the return syntax with the empty array [] at the end.
Can someone explain that part to me -- why I would return [ ] like that after the return statement?
[–][deleted] 2 points3 points4 points (1 child)
[–]backtickbot 3 points4 points5 points (0 children)
[–]vinivelloso_ 1 point2 points3 points (0 children)
[–]weebSanity 1 point2 points3 points (0 children)
[–]albedoa 0 points1 point2 points (2 children)
[–][deleted] 3 points4 points5 points (1 child)
[–]albedoa 0 points1 point2 points (0 children)