1. 프로그래머스
Lv1. 음양 더하기
const solution=(absolutes, signs)=> {
let answer = 0;
for(let i=0; i<signs.length; i++){
signs[i] ? answer+=absolutes[i] : answer-=absolutes[i]
}
return answer
}
function solution(absolutes, signs) {
return absolutes.reduce((acc, val, i) => acc + (val * (signs[i] ? 1 : -1)), 0);
}
arr.reduce(callback[, initialValue])