Created
July 4, 2020 03:39
-
-
Save andreiskandar/b314ea8deb2792b39969aad958d7e5d2 to your computer and use it in GitHub Desktop.
Create a function named camelCase that will convert a string to camel case, and return the result.
This file contains 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
/* | |
Create a function named camelCase that will convert | |
a string to camel case, and return the result. | |
*/ | |
const camelCase = function(input) { | |
let string = input.split(""); | |
string[0] = string[0].toLowerCase(); | |
for(let i = 0; i < string.length; i++) { | |
if(string[i] === " "){ | |
string[i+1] = string[i+1].toUpperCase(); | |
string[i] = string[i].replace(" ", ""); | |
} | |
} | |
return string.join(""); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment