I have an array [a, b, c]. I want to be able to insert a value between each elements of this array like that: [0, a, 0, b, 0, c, 0].
[a, b, c]
[0, a, 0, b, 0, c, 0]
I gues
Another way if you want to exclude the start and end of array is :
var arr = ['a', 'b', 'c'] var newArr = [...arr].map((e, i) => i < arr.length - 1 ? [e, 0] : [e]).reduce((a, b) => a.concat(b)) console.log(newArr)