* {
  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>프로그래머스 03) <br> 가운데 글자 가져오기</h3><hr><br>`)

function solution(s) {
    const leng = s.length
    document.write(`${s}의 가운데 글자는 `+`<span>${JSON.stringify(leng%2==1 ? s[parseInt(leng/2)] : s.slice((leng/2-1),(leng/2+1)))}</span>`+"입니다. <br>")
}

solution("abcde")
solution("qwer")

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.