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

Age calculator tool

🎂✨ Discover your age in detail and with countdown to your next birthday with fun facts! 🎈🎉

Calculate your age now!
Digamber - Author positronX.io

Hi, I'm Digamber Singh, a New Delhi-based full-stack developer, tech author, and open-source contributor with 10+ years' experience in HTML, CSS, JavaScript, PHP, and WordPress.