Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andreiskandar/b314ea8deb2792b39969aad958d7e5d2 to your computer and use it in GitHub Desktop.
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.
/*
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