Open In App

Lodash _.toUpper() Method

Improve
Improve
Like Article
Like
Save
Share
Report

Lodash _.toUpper() method is used to convert the entire string to Upper case. This method does not affect any of the special characters, digits, and the alphabets that are already in the upper case.

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.

Syntax:

_.toUpper( [string = ''..."])

Parameters:

This method accepts a single parameter as mentioned above and described below:

  • string: This parameter holds the string to convert.

Return Value:

This method returns the upper case string.

Example 1: In this example, the lodash library’s _.toUpper() method is employed to convert text to uppercase, producing uppercase versions of the provided strings.

Javascript




// Requiring the lodash library 
const _ = require("lodash"); 
      
// Use of _.toUpper() method
console.log(_.toUpper('Geeks-For-Geeks'));
console.log(_.toUpper('#--GeeksForGeeks--#'));


Output:

'GEEKS-FOR-GEEKS'
'#--GEEKSFORGEEKS--#'

Example 2: In this example, the lodash library’s _.toUpper() method is utilized to convert a given string, “Hello Geeks!”, to uppercase, resulting in “HELLO GEEKS!”.

Javascript




// Requiring the lodash library 
const _ = require("lodash"); 
 
//  Given string    
let str = "Hello Geeks!";
 
// Use of _.toUpper() method
console.log(_.toUpper(str));


Output:

'HELLO GEEKS!'

Last Updated : 09 Nov, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads