(프로그래머스) 가운데 글자 가져오기

유지원·2022년 4월 12일
0

프로그래머스

목록 보기
25/66

문제 링크

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


Javascript

function solution(s) {
    return s.substr(Math.ceil(s.length / 2) - 1, s.length % 2 === 0 ? 2 : 1);
}
profile
👋 https://github.com/ujw0712

0개의 댓글