작성
·
210
0
항상 감사합니다
function solution(question) {
let answer = "";
if (question.length > 100) return;
const oddNumber = question.length % 2 === 1 ? true : false;
const MiddleLength = Math.floor(question.length / 2);
let count = 0;
for (const z of question) {
if (oddNumber) {
if (MiddleLength === count) {
answer += z;
}
} else {
if (MiddleLength - 1 === count || MiddleLength === count) {
answer += z;
}
}
count++;
}
return answer;
}
console.log(solution("study")); //"u"
답변 1
0