Lodash _.toUpper() Method
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
const _ = require( "lodash" );
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
const _ = require( "lodash" );
let str = "Hello Geeks!" ;
console.log(_.toUpper(str));
|
Output:
'HELLO GEEKS!'
Last Updated :
09 Nov, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...