1. 프로그래머스
Lv1. 행렬의 덧셈
const solution=(arr1, arr2)=>{
let answer = [];
for(let i=0; i<arr1.length; i++){
const innerArray1 = arr1[i];
const innerArray2 = arr2[i];
const sumArray = [];
for (let j = 0; j < innerArray1.length; j++) {
const sum = innerArray1[j] + innerArray2[j];
sumArray.push(sum);
}
answer.push(sumArray);
}
return answer
}
function sumMatrix(A,B){
return A.map((arr1, idx1) => arr1.map((val, idx2) => val+B[idx1][idx2]));
}
function solution(arr1, arr2) {
var answer = [[]];
for (var i=0; i<arr1.length; i++){
answer[i] =[];
for(var j=0; j<arr1[i].length; j++){
answer[i].push(arr1[i][j] + arr2[i][j]);
}
}
return answer;
}