DEV Community

Discussion on: Capitalizing Words in Javascript

Collapse
 
therealokoro profile image
Okoro Redemption • Edited

Nice one @ian .

I created a JavaScript Utility Library that comes with so many useful functions and method all categorized into modules. One of this modules is the "Str", which contains methods that manipulates a string. And amongst close to 40 methods, capitalizing a string is one of them.

You can check it out on Github

To achieve this using the library, after installation(obviously)

// export the "Str" module's functions to a variable
var Str = ToolJS.export("Str");

// you could also just import the Str module from the libraries ESM version
// import { Str } from "https://unpkg.com/@redeakaa/tooljs@1.0.1/dist/esm/tooljs.esm.js";

// call the "capitalize" method on the string....
var capitalized = $.capitalize("hello everyone, give toolJS a try");
console.log(capitalized);
// => "Hello Everyone, Give ToolJS A Try"
Enter fullscreen mode Exit fullscreen mode