가운데 글자 가져오기

ccy·2022년 1월 14일

알고리즘(JS)

목록 보기
5/31

function solution(s) {
    let answer = '';
 
   if(s.length %2 ===0){
     answer=s[s.length/2-1] +s[s.length/2]
     
   }else{
     answer =s[Math.floor(s.length/2)]     
   }
    return answer;

}

solution("hospital")

profile
개발배우는중

0개의 댓글