Skip to content

Commit 0ca90b3

Browse files
committed
Add 이상한-문자-만들기.js
1 parent c810b7a commit 0ca90b3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

level-1/이상한-문자-만들기.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,18 @@ function solution(s) {
5454
5555
대, 소문자 변환, split, reverse, join, map 등등을 활용 해야 하므로
5656
문자열을 연습하는데 좋은 문제입니다.
57-
*/
57+
*/
58+
59+
//정답 4 - prove-ability
60+
function solution(s) {
61+
let answer = '';
62+
s.split(" ").forEach((word) => {
63+
for(let i = 0, len = word.length; i < len; i++) {
64+
if(i % 2 === 0) answer+=word[i].toUpperCase();
65+
else answer+=word[i].toLowerCase();
66+
}
67+
answer += " ";
68+
})
69+
answer = answer.slice(0, answer.length - 1)
70+
return answer;
71+
}

0 commit comments

Comments
 (0)