Lodash _.toUpper() Method

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

The _.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.

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:

Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

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

Example 2:  

Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

'HELLO GEEKS!'

full-stack-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.