Created
August 8, 2020 15:17
-
-
Save cplpearce/098a7758d788e24cef6abbfd519dd59a to your computer and use it in GitHub Desktop.
Kata 7 - Case Maker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const camelCase = function(input) { | |
let tempString = ""; | |
let capitalize = false; | |
for (let char of input) { | |
if (char === " ") { | |
capitalize = true; | |
continue; | |
} else if (capitalize === true) { | |
tempString += char.toUpperCase(); | |
capitalize = false; | |
continue; | |
} else { | |
tempString += char; | |
continue; | |
} | |
} | |
return tempString; | |
}; | |
console.log(camelCase("this is a string")); | |
console.log(camelCase("loopy lighthouse")); | |
console.log(camelCase("supercalifragalisticexpialidocious")); | |
/* | |
Output | |
thisIsAString | |
loopyLighthouse | |
supercalifragalisticexpialidocious | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment