es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
17 lines (14 loc) • 384 B
JavaScript
import { words } from './words.mjs';
function startCase(str) {
const words$1 = words(str.trim());
let result = '';
for (let i = 0; i < words$1.length; i++) {
const word = words$1[i];
if (result) {
result += ' ';
}
result += word[0].toUpperCase() + word.slice(1).toLowerCase();
}
return result;
}
export { startCase };