I am trying to, in a foreach
statement, to modify each of the array elements, in this case by adding a string.
var test = [["A","B"],["C","D"]]
test.forEach(function(test2){
test2 = test2.map(function(elem){
return elem+"_NEW STRING"
})
console.log(test2);
})
console.log(test);
However, the final variable is still the same as the original, no changes are made to the array contents, even though the middle console.log prints correctly.
What am I doing wrong? This seems a simple issue but I can't make it work right...
Thanks in advance!!