소문자로 된 단어(문자열)가 입력되면 그 단어의 가운데 문자를 출력하는 프로그램을 작성하세요. 단 단어의 길이가 짝수일 경우 가운데 2개의 문자를 출력합니다.
첫 줄에 문자열이 입력된다. 문자열의 길이는 100을 넘지 않습니다.
첫 줄에 가운데 문자를 출력합니다.
입력 1 : study
출력 1 : u
입력 2 : good
출력 2 : oo
const solution = (input) => {
return input.length % 2 === 0
? `${input[input.length / 2 - 1]}${input[input.length / 2]}`
: input[Math.floor(input.length / 2)];
};
const a = solution("study");
const b = solution("good");
console.log(a, b); // u oo