- Write a method that combines two Arrays passed in as arguments, and returns a new Array that contains all elements from both Array arguments, with the elements taken in alternation. You may assume that both input Arrays are non-empty, and that they have the same number of elements.
interleave([1, 2, 3], ['a', 'b', 'c'])
// returns [1, 'a', 2, 'b', 3, 'c']
- Refactor your method to handle two Arrays of different lengths and empty Arrays. The new array should always start with an element from the first array if possible.
interleave([1, 2], ['a', 'b', 'c' ,'d'])
// returns [1, 'a', 2, 'b', 'c', 'd']