Let's say that I have the following array:
const myArray = ["q", "w", "e", "r", "t", "y"]
What I would like to do is to add an element between all the elements, like this:
myArray.someMethod("XXX")
// ["q", "XXX", "w", "XXX", "e", "XXX", "r", "XXX", "t", "XXX", "y"]
In a way, it is kinda what .join
does, but I would like the output to be another array, instead of a string.
I know how to do this with a loop, but I would like to know is the "functional" way to achieve this.