솔루션
const solution = (cipher, code) => {
const str = [...cipher];
const answer = str.reduce(
(a, c, i) => ((i + 1) % code === 0 ? a + c : a),
""
);
console.log(answer);
return answer;
};
솔루션
const solution = (cipher, code) => {
const answer = [];
for (let i = code - 1; i < cipher.length; i += code) {
answer.push(cipher[i]);
}
console.log(answer.join(""));
return answer.join("");
};
솔루션
const solution = (cipher, code) => {
const answer = cipher
.split("")
.filter((v, i) => (i + 1) % code === 0)
.join("");
console.log(answer);
return answer;
};