지난 풀이 참고
지난 풀이 참고
n만큼 인덱스를 더한다.더해진 인덱스 -= 배열 길이 로 다시 인덱스를 배열의 맨 처음부터 시작하게 한다.function solution(s, n) {
    const ABC = ["A","B","C","D","E","F","G","H","I","J","K","L",'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
    const abc = ABC.map((el) => el.toLowerCase());
    let answer = "";
    const arr = s.split("");
    
    arr.forEach((el) => {
        if(ABC.indexOf(el) !== -1) {
            const idx = ABC.indexOf(el);
            let newIdx = idx + n;
            if(newIdx >= ABC.length) newIdx = newIdx - ABC.length; 
            answer += ABC[newIdx];
        }
        else if(abc.indexOf(el) !== -1) {
            const idx = abc.indexOf(el);
            let newIdx = idx + n;
            if(newIdx >= abc.length) newIdx = newIdx - abc.length; 
            answer += abc[newIdx];
        } else {
            answer += el;
        }
    })
    return answer;
}