How to Uppercase a String in Javascript?

If you want to easily capitalize a string in JavaScript to uppercase, you can use this simple snippet of code:

var str = "Hello World!";
var newStr = str.toUpperCase();

The result will be:

"HELLO WORLD!"

You can also capitalize only the first letter of a string or lowercase the whole string.

LEAVE A REPLY

Please enter your comment!
Please enter your name here