.toUpperCase()
Anonymous contributor
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:
nyNY
Codebyte Example
Here is a codebyte example that shows the use of the .toUpperCase()
method:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn JavaScript on Codecademy
- Career path
Front-End Engineer
Front-end engineers work closely with designers to make websites beautiful, functional, and fast.Includes 34 CoursesWith Professional CertificationBeginner Friendly115 hours - Free course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner Friendly15 hours