Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit db35cbf

Browse files
Add 시저-암호.js
1 parent 1ee9c89 commit db35cbf

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎level-1/시저-암호.js‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,23 @@ function solution(s, n) {
6060
}
6161
}
6262
return result;
63+
}
64+
65+
//정답 4 - prove-ability
66+
function solution(s, n) {
67+
var answer = '';
68+
for(let i = 0, len = s.length; i < len; i++) {
69+
if(s[i] === " ") {
70+
answer += " ";
71+
continue;
72+
}
73+
let index = s[i].charCodeAt();
74+
// 65 - 90
75+
// 97 - 122
76+
if(index <= 90 && index + n > 90) index -= 26;
77+
else if (index + n > 122) index -= 26;
78+
79+
answer += String.fromCharCode(index + n)
80+
}
81+
return answer;
6382
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /