I am trying to loop through and concatenate 2 arrays such as below, I don’t know how many values there will be as a user could purchase 1 or 100 products so it needs to loop.
Array1 = ['ABC', 'DEF', 'GHI']
Array2 = ['123', '45', '6789',]
I need to output to be:
ABC:123|DEF:45|GHI:6789
Currently code I have...
function() {
var array_one = ['ABC', 'DEF', 'GHI', 'JKL'];
var array_two = ['179.99', '349.99', '399.99', '389'];
for (var i = 0; i < array_one.length; i++) {
for (var j = 0; j < array_two.length; j++) {
return(array_one[i] + ":" + array_two[j] + "|");
}
}
}
This only outputs one value and doesn't loop through, any ideas where my loop is breaking.