JavaScript – Convert String to Uppercase

To convert a string to uppercase in JavaScript, call toUpperCase() method on the string. The expression returns a new string with all the characters of the calling string transformed to uppercase.

Syntax

The syntax to call toUpperCase() function on the string str is

str.toUpperCase()

toUpperCase() returns a new string with the contents of the original string transformed to uppercase.

ADVERTISEMENT

Examples

In the following example, we take a string str, convert this string to uppercase, and display both the original string, and uppercase transformed string in #output.

index.html

Conclusion

In this JavaScript Tutorial, we learned how to transform a given string to uppercase in JavaScript, using toUpperCase() method, with examples.