Answers for "reduce javascript acc became numeber insted array"

1

js reduce

Sum array elements:
let myArr = [1,2,3,-1,-34,0]
return myArr.reduce((a,b) => a + b,0)
Posted by: Guest on December-27-2020
0

reduce javascript acc became numeber insted array

const secondArray = [1, 2, 3].reduce((acc, item) => {
    acc.push(1);

    return acc;
}, []);

console.log(secondArray);
Posted by: Guest on January-18-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language