Last active
August 21, 2020 08:36
-
-
Save yungyungGwon/a614034125206cd17e246550bd8f80e2 to your computer and use it in GitHub Desktop.
Algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(s,n){ | |
var answer = ""; | |
var check = ""; | |
for(var i = 0; i < s.length; i++){ | |
check = s.charCodeAt(i); | |
if(check == 32){ | |
answer += " "; | |
} | |
else if (check >= 65 && check <= 90){ | |
if(check + n > 90){ | |
answer += String.fromCharCode(check + n - 26); | |
}else{ | |
answer += String.fromCharCode(check + n); | |
} | |
} | |
else if(check >= 97 && check <= 122){ | |
if(check + n > 122){ | |
answer += String.fromCharCode(check + n - 26); | |
}else{ | |
answer += String.fromCharCode(check + n); | |
} | |
} | |
} | |
return answer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment