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
// Requiring the lodash library const _ = require( "lodash" ); // Use of _.toUpper() method console.log(_.toUpper( 'Beginner-For-Beginner' )); console.log(_.toUpper( '#--w3wiki--#' )); |
Output:
'Beginner-FOR-Beginner'
'#--w3wiki--#'
Example 2: In this example, the lodash library’s _.toUpper()
method is utilized to convert a given string, “Hello Beginner!”, to uppercase, resulting in “HELLO Beginner!”.
Javascript
// Requiring the lodash library const _ = require( "lodash" ); // Given string let str = "Hello Beginner!" ; // Use of _.toUpper() method console.log(_.toUpper(str)); |
Output:
'HELLO Beginner!'
Contact Us