어쨌든 arr1, arr1[i]로 파고 들어가는 게 핵심
function solution(arr1, arr2) {
let answer = [];
let tmp = [];
for (let i=0; i<arr1.length; i++) {
for (let j=0; j<arr1[i].length; j++) {
tmp.push(arr1[i][j]+arr2[i][j]);
}
answer.push(tmp.slice());
tmp.length=0;
}
return answer;
}
console.log(
solution(
[[1, 2], [2, 3]],
[[3, 4], [5, 6]]
)
);
function solution(A, B) {
return A.map((a,i) => a.map((b, j) => b + B[i][j]));
}
console.log(
solution(
[[1, 2], [2, 3]],
[[3, 4], [5, 6]]
)
);
function solution(A, B) {
var answer = Array();
for(let i=0;i<A.length;i++){
var newarr = A[i].map(function(item, index, A){
return item + B[i][index];
});
answer[i] = newarr;
}
return answer;
}
console.log(
solution(
[[1, 2], [2, 3]],
[[3, 4], [5, 6]]
)
);