To convert a string into lowercase characters in JavaScript, use the toLowerCase() method. The toUpperCase() method takes no arguments and returns a converted uppercase string.
Javascript toUpperCase
Javascript toUpperCase() is a built-in string function that converts a string to uppercase letters. The toUpperCase() method returns the calling string value converted to uppercase.
To convert a string to uppercase in JavaScript, use the toUpperCase() method. The toUpperCase() method does not affect the value of the string since JavaScript strings are immutable. However, you cannot call this method null or undefined. If you call them, you will get a TypeError will be thrown.
Syntax
See the syntax below.
string.toUpperCase()
Example
Let’s see the example.
// app.js let strA = 'avengers will be a great movie'; console.log(strA.toUpperCase());
The output is the following.
The String toUpperCase() function converts an entire string to the Upper case. Therefore, the function does not affect any special characters, digits, and alphabets already in the upper case.
See more examples.
// app.js console.log('appdividend'.toUpperCase()); console.log('krunallathiya'.toUpperCase());
See the output below.
That’s it for converting string to uppercase in the JavaScript tutorial.
Related posts
Javascript String toLocaleUpperCase()