.toUpperCase()

Published Jun 19, 2021Updated Jun 19, 2024
Contribute to Docs

In JavaScript, the .toUpperCase() method converts the lowercase letters of a string to uppercase.

Syntax

string.toUpperCase();
  • string: The string to be used for conversion.

Example 1

Here is an example that demonstrates the usage of the .toUpperCase() method:

console.log('hello world'.toUpperCase());

The output of the above code is as follows:

HELLO WORLD

Example 2

The .toUpperCase() method doesn’t modify the original string, as shown below:

var state = 'ny';
state.toUpperCase();
console.log(state);
console.log(state.toUpperCase());

The above code produces the following output:

ny
NY

Codebyte Example

Here is a codebyte example that shows the use of the .toUpperCase() method:

Code
Output
Loading...

All contributors

Looking to contribute?

Learn JavaScript on Codecademy