-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJadenCase.js
More file actions
28 lines (25 loc) · 1.15 KB
/
Copy pathJadenCase.js
File metadata and controls
28 lines (25 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// JadenCase란 모든 단어의 첫 문자가 대문자이고, 그 외의 알파벳은 소문자인 문자열입니다. 단, 첫 문자가 알파벳이 아닐 때에는 이어지는 알파벳은 소문자로 쓰면 됩니다. (첫 번째 입출력 예 참고)
// 문자열 s가 주어졌을 때, s를 JadenCase로 바꾼 문자열을 리턴하는 함수, solution을 완성해주세요.
// 제한 조건
// s는 길이 1 이상 200 이하인 문자열입니다.
// s는 알파벳과 숫자, 공백문자(" ")로 이루어져 있습니다.
// 숫자는 단어의 첫 문자로만 나옵니다.
// 숫자로만 이루어진 단어는 없습니다.
// 공백문자가 연속해서 나올 수 있습니다.
// 입출력 예
// s return
// "3people unFollowed me" "3people Unfollowed Me"
// "for the last week" "For The Last Week"
function solution(s) {
var answer = "";
let arr = s.split(" ");
let arr1 = arr.map(
(a) => a.charAt(0).toUpperCase() + a.slice(1).toLowerCase()
);
// let arr2 = arr.map(a =>no a.slice(1).toLowerCase())
console.log("1", arr1);
let arr2 = arr1.join(" ");
return arr2;
}
let s = "3people unFollowed me";
console.log(solution(s));