Open In App

Lodash _.upperFirst() Method

Last Updated : 27 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Lodash _.upperFirst() method is used to convert the first character of the string to the upper case.

Syntax:

_.upperFirst( [string = '']);

Parameters:

  • string: This parameter holds the string to convert.

Return Value:

This method returns the converted string.

Example 1: In this example, we are printing the first alphabet capital of the given string in the console by the use of the lodash _.upperFirst() method.

Javascript




// Requiring the lodash library 
const _ = require("lodash");
 
// Use of _.upperFirst() method
console.log(_.upperFirst('geeks-For-geeks'));


Output:

'Geeks-For-geeks'

Example 2: In this example, the given string is already in capital letters so it will print it same.

Javascript




// Requiring the lodash library 
const _ = require("lodash"); 
      
// Use of _.upperFirst() method
console.log(_.upperFirst('GEEKS FOR GEEKS'));


Output:

'GEEKS FOR GEEKS'

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads