Write a function addArrays that takes 2 arrays of numbers as parameters and returns a new array where elements at same index position are added together. For example: addArrays([1,2,3], [4,3,2,1]); // => [5,5,5,1]
I am trying to use nested for loops but its giving an incorrect answers....
function addArrays(num1, num2){
var result = [];
for(var i=0; i< num1.length; i++){
for(var j=0; j<num2.length; j++){
result.push(num1[i] + num2[j]);
}
}
return result;
}