How to Convert Strings to Uppercase with JavaScript?

Last Updated on by in JavaScript

JavaScript offers a powerful method to convert string to uppercase; however, this can also be achieved with CSS. We simply store the string in variable and bind it with toUpperCase() method. It converts the string and returns the new value in uppercase form. As we know JavaScript strings are immutable, so it doesn’t affect the value of the string.

As far as the browser support is concerned this method is supported by almost every browser.

JavaScript’s toUpperCase() example.

let string = 'a part of the journey is the end.';

string.toUpperCase();
// output: "A PART OF THE JOURNEY IS THE END."

JavaScript toUpperCase() Syntax

str.toUpperCase()

str: attach a new string with the method; it will return the converted string to uppercase.

let string = 'hello this is dummy content';

let upper = string.toUpperCase();

console.log(upper)

// output: HELLO THIS IS DUMMY CONTENT