Created
May 3, 2022 14:23
-
-
Save blessedjasonmwanza/2ad9150e3d360b98405c7f015d98636e to your computer and use it in GitHub Desktop.
Capitalize first character of each word
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
// Adapted from : https://www.codewars.com/kata/5390bac347d09b7da40006f6/train/javascript | |
String.prototype.toJadenCase = function () { | |
let str = this.toString(); | |
// split it to an array, | |
// capitalize each item | |
// join it with a space | |
str = str.split(' '); | |
return str.map(word => word.charAt(0).toUpperCase()+ word.slice(1)).join(' '); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment