[프로그래머스] 시저 암호😥

GoGoDev·2021년 6월 23일
0

Programmers Lv.1🌱

목록 보기
40/46

https://programmers.co.kr/learn/courses/30/lessons/12926#

function solution(s, n) {
    var answer = '';
    for(let i = 0; i < s.length; i++){
        if(s.charCodeAt(i) === 32){
            answer += ' ';
        }else{
            answer += String.fromCharCode((s.charCodeAt(i)) > 90
                ? (s.charCodeAt(i)+n-97)%26+97 
                : (s.charCodeAt(i)+n-65)%26+65)
        }
    }
    return answer;
}
profile
🐣차근차근 무럭무럭🐣

0개의 댓글