6 kyu
From..To..Series #7: from sentence to camelCase. Can you convert it?
182 of 378myjinxin2015
Description:
Description:
Give you a sentence s
. It contains some words and separated by spaces. Another arguments is n
, its a number(1,2 or 3). You should convert s
to camelCase n.
There are three kinds of camelCase:
camelCase 1: The first letter of each word should be capitalized.
Except for the first word.
Example: "Hello world" --> "helloWorld"
camelCase 2: The last letter of each word should be capitalized.
Except for the last word.
Example: "Hello world" --> "hellOworld"
camelCase 3: The first and last letters of each word should be capitalized.
Except for the first and lasts letter of sentence.
Example: "Hello world" --> "hellOWorld"
You can assume that all of the input data is valid. That is: s
always be a string; It contains at least two words; Each word contains only letters(a-zA-Z); Each word contains ar least three letters; n
always be 1,2 or 3.
Examples
toCamelCase("hello world",1) === "helloWorld"
toCamelCase("hello world",2) === "hellOworld"
toCamelCase("hello world",3) === "hellOWorld"
toCamelCase("Hello world",1) === "helloWorld"
toCamelCase("Each number plus one",1) === "eachNumberPlusOne"
toCamelCase("Each number plus one",2) === "eacHnumbeRpluSone"
toCamelCase("Each number plus one",3) === "eacHNumbeRPluSOne"
Random tests may contains bug(I'm not sure), please test and feedback, thanks ;-)
Puzzles
Similar Kata:
Stats:
Created | Oct 21, 2016 |
Published | Oct 21, 2016 |
Warriors Trained | 690 |
Total Skips | 6 |
Total Code Submissions | 1969 |
Total Times Completed | 378 |
JavaScript Completions | 182 |
Python Completions | 178 |
Ruby Completions | 37 |
Total Stars | 12 |
% of votes with a positive feedback rating | 90% of 138 |
Total "Very Satisfied" Votes | 115 |
Total "Somewhat Satisfied" Votes | 18 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 6 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |