DEV Community

Discussion on: What’s your alternative solution? Challenge #50

Collapse
 
swkidd profile image
swkidd • Edited

Using toString to flatten the array:

const sumArray = ar => JSON.parse(`[${ar.toString()}]`).reduce((a,c) => a + c)