JavaScript Basics

JavaScript Advanced

JavaScript Arrays

JavaScript Functions

JavaScript Objects

JavaScript DOM

JavaScript String

How to convert string to uppercase in JavaScript?

If you want to convert all the letters in a string to uppercase, then use the toUpperCase() method. It is important to note that the toUpperCase() method does not modify the original string and returns a new string having all characters in uppercase.

The syntax for the toUpperCase() method is:

let upperCaseString = string.toUpperCase();

The following example converts all the characters in a string to uppercase:

let str = "JavaScript String";
let newString = str.toUpperCase();

console.log(newString); //JAVASCRIPT STRING
console.log(str); //JavaScript String

Recommended Posts