I have an array [1,2,3,4,5,6] and a separator '~' and I want to joint them into a new array with '~' being the separator.
I'd like the output to be [1,'~', 2,'~', 3,'~', 4,'~', 5,'~', 6].
Using Lodash I got something like:
var my_array = [1,2,3,4,5,6]
var separator = '~'
_.flatten(_.zip(my_array, new Array(my_array.length).fill(separator)))
But this feels ugly and I'm sure there is a better way.
EDIT: Even though the array above has ints I'd like this to work for any type of object.