코딩 테스트/test_javaScript

[코딩테스트/javaScript] 행렬의 덧셈

ijooha 2024. 12. 30. 21:39

function solution(arr1, arr2) {
    let a = arr1.length;
    let b = arr1[0].length;
    let answer = [];
    
    for (let i=0; i<a; i++) {
        let row = [];
        
        for (let j=0; j<b; j++) {
            row.push(arr1[i][j] + arr2[i][j]);
        } 
        answer.push(row);
    } 
    return answer;
}