Skip to content

Latest commit

 

History

History
57 lines (35 loc) · 1.23 KB

title.md

File metadata and controls

57 lines (35 loc) · 1.23 KB

Title

This module provides a class for converting the first character of each word in a string to uppercase, effectively capitalizing the words.

Installation

To use this module, you should have the "node-string-methods" npm package installed. You can install it using npm or yarn:

npm install node-string-methods

Usage

const Title = require('node-string-methods/title');

// Create an instance of the Title class with a string
const str = 'hello world';
const titleConverter = new Title(str);

// Execute the title-case conversion
const result = titleConverter.execute();

console.log(result);
// Output: 'Hello World'

Constructor

new Title(str)

  • str (String): The input string that you want to convert to title case.

Creates a new instance of the Title class with the provided input string.

Methods

execute()

Converts the input string to title case by capitalizing the first character of each word.

  • Returns: A new string in title case.

Example

const Title = require('node-string-methods/title');

const str = 'hello world';
const titleConverter = new Title(str);

const result = titleConverter.execute();

console.log(result);
// Output: 'Hello World'