JavaScript String toUpperCase() method

The toUpperCase() method in JavaScript is used to convert all the characters in a string to their uppercase equivalent. This method does not take any arguments, and returns a new string with all the characters in the original string converted to uppercase.

Here is an example of how the toUpperCase() method works:

const string1 = 'Hello, world!';

const result = string1.toUpperCase();

// the result will be: 'HELLO, WORLD!'

In the code example above, we first declare a string called string1 that contains the text Hello, world!. We then use the toUpperCase() method to convert all the characters in the string1 string to their uppercase equivalent. The toUpperCase() method does not take any arguments, so we simply call the method on the string1 string without passing any arguments.

As a result of calling the toUpperCase() method, the result variable will be set to 'HELLO, WORLD!', which is the string1 string with all the characters converted to uppercase. If the string1 string did not contain any lowercase characters, the result variable would be set to the original string1 string.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: