Trying to make a function that returns UpperCamelCase
if true is passed, and lowerCamelCase
if false.
I've got the first bit ok so far, but can't figure out how to ignore the first letter of the string. I've used charAt[0]
but that returns only the first character.
I've seen these threads but cannot find out how to do it.
This is my code so far:
function sentenceToCamelCase(str, bool) {
if (bool) {
return str
.toLowerCase()
.split(" ")
.map(w => w[0].toUpperCase() + w.substr(1))
.join("");
} else {
return str
.toLowerCase()
.split(" ")
.map(w => w[0].toUpperCase() + w.substr(1))
.join("");
}
}
I get this error:
AssertionError: expected 'ThisSentence' to deeply equal 'thisSentence'
Very new to JS, could anyone give me a hand? Thank you.