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 b44d07f

Browse files
Update JadenCase-문자열-만들기&12951&.js
풀이 추가
1 parent a6cc9e8 commit b44d07f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,14 @@ function solution(s) {
3535
}
3636
return answer.join(" ");
3737
}
38+
39+
//정답 4 - RyanDeclan
40+
41+
function solution(s) {
42+
return s.toLowerCase().split(" ").map(x=>x[0] ? x[0].toUpperCase() + x.substring(1) : "").join(" ");
43+
}
44+
45+
// 이 문제에서 제일 핵심은 "공백문자가 연속해서 나올 수 있습니다." 입니다. 이 부분을 꼭 고려하셔야합니다.
46+
// 왜냐하면 공백이 연속으로 있으면 split할때 공백이 포함되기에 그 공백이 마침 x[0]이 되어버리면 undefined.toUpperCase()가 되기에 런타임에러가 뜹니다.
47+
// 따라서 저는 풀때 당시 몰랐지만 chartAt()을 사용하는 것도 좋은 방법중 하나라고 생각합니다.
48+
//그게 아니라 이 코드로 한다면 꼭 undefined인 경우를 처리하는 코드를 추가해줘야합니다.

0 commit comments

Comments
(0)

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