I am trying to add the values โโof two arrays in javascript, for example. [1,2,1] + [3,2,3,4]
The answer should be 4,4,4,4, but I either get 4,4,4 or 4,4,4, NaN if I change the length of the 1st array to 4.
I know that the fourth number should be in the 1st array, but I cannot figure out how to say javascript to make it 0, and not undefined if there is no number.
javascript arrays nan
Jonas
source share