https://programmers.co.kr/learn/courses/30/lessons/12903
function solution(s) {
var answer = '';
var lenS = s.length;
var index1 = 0;
var index2 =0;
if((lenS % 2) === 0){
index1 = lenS/2 -1;
index2 = lenS/2;
answer = s.substring(index1, index2+1);
}else{
index1 = (lenS-1)/2;
index2 = (lenS-1)/2+1;
answer = s.substring(index1, index2);
}
return answer;
}
function solution(s) {
var answer = '';
var length = s.length;
if (length%2 === 0){ //even number
var result = length/2;
answer = s[result-1]+s[result];
} else { //odd number
var result = (length+1)/2;
answer = s[result-1];
}
return answer;
}
#짝수홀수