(프로그래머스) 음양 더하기

유지원·2022년 1월 11일
0

프로그래머스

목록 보기
7/66
post-thumbnail

문제 링크

https://programmers.co.kr/learn/courses/30/lessons/76501?language=javascript


Javascript

function solution(absolutes, signs) {
  return absolutes.reduce((a, v, i) => a + (v * (signs[i] ? 1 : -1)), 0);
  // let answer = 0
  // for (let i in absolutes) {
  //   answer += signs[i] ? absolutes[i] : -absolutes[i]
  // }
  // return answer
}
profile
👋 https://github.com/ujw0712

0개의 댓글

Powered by GraphCDN, the GraphQL CDN