Full-time web dev; JS lover since 2002; CSS fanatic. #CSSIsAwesome
I try to stay up with new web platform features. Web feature you don't understand? Tell me! I'll write an article!
He/him
Full-time web dev; JS lover since 2002; CSS fanatic. #CSSIsAwesome
I try to stay up with new web platform features. Web feature you don't understand? Tell me! I'll write an article!
He/him
Ah, you're right, that's interesting. I hadn't noticed that discrepancy with the capital 'C' in 'CaSe'; that makes this a more interesting challenge!
The original post should probably call that out a little more clearly, because it raises additional questions: Should punctuation count as a word separator? e.g., should 'word-other' become 'WoRd-oThEr' or 'WoRd-OtHeR'? Or should we only worry about letters and spaces? What characters are we considering?
Here goes a simple oneliner:
And the result:
I believe
case
should be printed asCaSe
as first letter (index 0) should be always capitalized.Indeed! Didn't catch that! Here is a little fix for that:
which output is:
Index 0 refers to the first letter of the entire string; we don't need to consider each word separately, just the string as a whole
Sorry about that.
I meant it as
index 0
of each word.the example shows the result should be
Ah, you're right, that's interesting. I hadn't noticed that discrepancy with the capital 'C' in 'CaSe'; that makes this a more interesting challenge!
The original post should probably call that out a little more clearly, because it raises additional questions: Should punctuation count as a word separator? e.g., should 'word-other' become 'WoRd-oThEr' or 'WoRd-OtHeR'? Or should we only worry about letters and spaces? What characters are we considering?
@thepracticaldev , any help here?
For some reason, CodeWars isn't loading for me so won't be able to check the edge cases... 🤔