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]
.
I guess it would be something like this, but I can't make it works.
for (let i = 0; i < array.length; i++) {
newArray = [
...array.splice(0, i),
0,
...array.splice(i, array.length),
];
}
Thank you for helping me!