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

Sub #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Ryan-Dia wants to merge 2 commits into codeisneverodd:main from Ryan-Dia:sub
Closed

Sub #103

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update JadenCase-문자열-만들기&12951&.js
풀이 추가
  • Loading branch information
Ryan-Dia authored Sep 22, 2022
commit b44d07f82a9c0792e08f6bdb15d7cc9e8396972c
11 changes: 11 additions & 0 deletions level-2/JadenCase-문자열-만들기&12951&.js
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,14 @@ function solution(s) {
}
return answer.join(" ");
}

//정답 4 - RyanDeclan

function solution(s) {
return s.toLowerCase().split(" ").map(x=>x[0] ? x[0].toUpperCase() + x.substring(1) : "").join(" ");
}

// 이 문제에서 제일 핵심은 "공백문자가 연속해서 나올 수 있습니다." 입니다. 이 부분을 꼭 고려하셔야합니다.
// 왜냐하면 공백이 연속으로 있으면 split할때 공백이 포함되기에 그 공백이 마침 x[0]이 되어버리면 undefined.toUpperCase()가 되기에 런타임에러가 뜹니다.
// 따라서 저는 풀때 당시 몰랐지만 chartAt()을 사용하는 것도 좋은 방법중 하나라고 생각합니다.
//그게 아니라 이 코드로 한다면 꼭 undefined인 경우를 처리하는 코드를 추가해줘야합니다.

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