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 9061967

Browse files
jaewon1676prove-ability
authored andcommitted
Add 220418 JadenCase-문자열-만들기.js 1개의 풀이 추가
1 parent bbd37bf commit 9061967

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

‎level-2/JadenCase-문자열-만들기.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,19 @@ function solution(s) {
66
answer = s.split(' ').map(word => word.charAt(0).toUpperCase() + word.substring(1).toLowerCase()).join(' ')
77
//word[0]은 빈 문자열을 만나면 undefined를, word.charAt(0)은 빈 문자열을 만나면 빈 문자열을 반환한다.
88
return answer;
9-
}
9+
}
10+
11+
//정답 2 - jaewon1676
12+
function solution(s) {
13+
s = s.split(' ').map(el => el.split('').map((el, index) =>
14+
index == 0 ? el.toUpperCase() : el.toLowerCase()).join('')).join(' ')
15+
return s;
16+
}
17+
// 문자열을 연습하기에 좋은 문제입니다.
18+
19+
// s.split(' ') // 띄어쓰기를 기준으로 나눕니다.
20+
// .map(el => el.split('')) 나눈 덩어리를 다시 요소 하나 하나씩 나눠줍니다
21+
// .map((el, index) => index == 0 ? el.toUpperCase() : el.toLowerCase())
22+
// 덩어리의 요소가 첫번째이면 대문자, 그렇지 않으면 소문자로 변환 해줍니다.
23+
// .join('') 작은 배열들을 합쳐줍니다.
24+
// .join(' ') 큰 배열들을 합쳐줍니다.

0 commit comments

Comments
(0)

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