Code has been added to clipboard!

toUpperCase

Reading time 2 min
Published Sep 8, 2017
Updated Oct 2, 2019

JavaScript upperCase: Main Tips

  • This method is used to convert all letters in a specified string to JavaScript uppercase.
  • The toUpperCase() method does not affect the original string, returning a new modified string instead.

Function Explained

Once you apply JavaScript toUpperCase() method to a string, all of the lower case letters will be capitalized. Therefore, JavaScript upperCase method is perfectly-suited for quickly converting all letters in a specified string in JavaScript uppercase.

However, there are some additional factors you have to bear in mind. For instance, the toUpperCase JavaScript method will not modify numbers, special characters and will retain the originally-capitalized letters.

Furthermore, the original string you want to change with the JavaScript toUpperCase() function won't be modified. Instead, the method generates a new string with all letters properly capitalized.

This example illustrates how you can easily capitalize letters with the toUpperCase JavaScript method:

Example
var str = "Hi, Mark!";
var res = str.toUpperCase();

By using the JavaScript upperCase function, we can also implement the JavaScript capitalize first letter task. In cases when you only want to have the first letter capitalized, you should apply uppercaseFirstLetter to strings.

Tip: toLowerCase() method can be used for converting the string to lowercase letters.

Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid certificates of completion
Coursera
Pros
  • Professional service
  • Flexible timetables
  • A variety of features to choose from
Main Features
  • Professional certificates of completion
  • University-level courses
  • Multiple Online degree programs
Datacamp
Pros
  • Great user experience
  • Offers quality content
  • Very transparent with their pricing
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable

Learn Standard Syntax

As you can see from the example below, the rules for writing JavaScript toUpperCase function do not require to remember many things. The most prominent feature is the capitalization of the method which you should attempt to keep in your code:

string.toUpperCase()

You should notice that parentheses are empty, meaning that it does not take any arguments.

Return Value

The JavaScript upperCase method will return an obvious value: a newly-generated string. All of the letters in the string will be capitalized, while the original string remains the same.

Return Value: A string, which represents the original string with the letters all converted to uppercase.
JavaScript Version: ECMAScript 1

Latest Udacity Coupon Found:

Verified STAFF PICK

75% OFF COURSES

Udacity Black Friday Offer

The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!

Expiration date: 08/03/2021
3176 People Used
Only 97 Left
Rating
5.0