I have a list [a, b, c]. I am trying to figure out how to insert the value 0 between each element of this list, resulting in [0, a, 0, b, 0, c, 0].
I attempted the following code snippet, but unfortunately it is not functioning as expected.
for (let i = 0; i < array.length; i++) {
newArray = [
...array.slice(0, i),
0,
...array.slice(i)
];
}
Your assistance with this matter is greatly appreciated!