This module provides a class for checking if a string follows the title case format, where the first letter of each word is capitalized.
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-methodsconst IsTitle = require('node-string-methods/isTitle');
// Create an instance of the IsTitle class with a string
const str1 = 'Title Case Example';
const str2 = 'Not Title Case';
const titleChecker1 = new IsTitle(str1);
const titleChecker2 = new IsTitle(str2);
// Execute the isTitle operation
const result1 = titleChecker1.execute();
const result2 = titleChecker2.execute();
console.log(result1); // Output: true
console.log(result2); // Output: falsestr(String): The input string that you want to check as following the title case format.
Creates a new instance of the IsTitle class with the provided input string.
Checks if the input string follows the title case format, where the first letter of each word is capitalized.
- Returns:
trueif the input string follows the title case format,falseotherwise.
const IsTitle = require('node-string-methods/isTitle');
const str1 = 'Title Case Example';
const str2 = 'Not Title Case';
const titleChecker1 = new IsTitle(str1);
const titleChecker2 = new IsTitle(str2);
const result1 = titleChecker1.execute();
const result2 = titleChecker2.execute();
console.log(result1); // Output: true
console.log(result2); // Output: false