I have the following code:
function transposeTwoStrings(arr){
var stringOne = arr[0];
var stringTwo = arr[1];
for (var i = 0; i < arr.length; i++) {
return (stringOne.charAt(i) + " " + stringTwo.charAt(i));
}
I am expecting output as follows:
e.g. transposeTwoStrings(['Hello','World']);
should return
H W
e o
l r
l l
o d
However it is only returning the first character at the first index of each string. I am trying to return all characters for both strings.
I initially had a much more verbose solution using if/else and decided to refactor using for loop.
I am stuck as output currently being shown when executed is
H W