[05.05.22] Coding test

Juyeon.it·2022년 5월 4일
0

Coding test

목록 보기
24/32

CamelCase Method

Description

Write simple .camelCase method (camel_case function in PHP, CamelCase in C# or camelCase in Java) for strings. All words must have their first letter capitalized without spaces.
For instance:
"hello case".camelCase() => HelloCase
"camel case word".camelCase() => CamelCaseWord

My answer

String.prototype.camelCase=function(){
  return this.split(' ').map(function(word) {
    return word.charAt(0).toUpperCase() + word.slice(1)
  }).join('')
}

0개의 댓글

관련 채용 정보