* {
  background-color : black;
  color : white;
  word-break: keep-all;
}

body {
  text-align:center;
  padding-top : 20px;
  font-size : 20px;
}

span {
  color:red;
  font-size:25px;
}
document.write(`<hr><h3>프로그래머스 04) <br> 두 정수 사이의 합</h3><hr><h6 style="color:orange;">이 때 두 수가 동률이면, 하나만 출력한다.</h6>`)

function solution(a,b) {
  const item = a==b ? a :
    Array.from({length: (a-b)>0 ? a-b+1 : b-a+1}, (el, i) => 
      (a-b)>0 ? b+i : a+i).reduce((acc, cur)=> acc+cur,0) 
    document.write(`두 정수 사이의 합은 <br> <span>${JSON.stringify(item)}</span>`+"입니다. <br>")
}

solution(3, 5)

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.