UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

16 lines (15 loc) 600 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ucfirst = ucfirst; function ucfirst(str) { // discuss at: https://locutus.io/php/ucfirst/ // parity verified: PHP 8.3 // original by: Kevin van Zonneveld (https://kvz.io) // bugfixed by: Onno Marsman (https://twitter.com/onnomarsman) // improved by: Brett Zamir (https://brett-zamir.me) // example 1: ucfirst('kevin van zonneveld') // returns 1: 'Kevin van zonneveld' str += ''; const f = str.charAt(0).toUpperCase(); return f + str.substr(1); }