Skip to main content
@spa-tools/utilities

formatProperCase()

The formatProperCase() function takes a string and returns it with each word proper cased.

Usage

import { formatProperCase } from '@spa-tools/utilities';

const value1 = 'hello world';
const proper1 = formatProperCase(value1);
console.log(proper1);
// --> 'Hello World'

const value2 = 'HELLO WORLD';
const proper2 = formatProperCase(value2);
console.log(proper2);
// --> 'Hello World'

const value3 = 'hello-world';
const proper3 = formatProperCase(value3);
console.log(proper3);
// --> 'Hello-World'

Arguments

NameTypeDescription
strstringThe value to proper case

Returns

Returns a string.