JavaScript Uppercase Tutorial with Examples – POFTUT

JavaScript Uppercase Tutorial with Examples

JavaScript programming language provides functions in order to change the case of the given string, word or sentence. toUpperCase() is the main function that can be used to make the given string, word and sentence completely uppercase.

toUpperCase() Function Syntax

toUpperCase() function is provided by a JavaScript string object where it can be called with this object directly. toUpperCase() function does not require any parameter as it will use the object value as a parameter to capitalize.

  • OBJECT is the string value we want to make uppercase. This value can be a letter, word, sentence simply a string data type.
  • toUpperCase() is the function we will use to make the OBJECT value uppercase. This function will return the upper

toUpperCase() Examples

toUpperCase() function is related to the string object and can be called from a string variable or string literal like below. In this following example, we will create a string variable named sitename and call the toUpperCase() function and assign the returned value into the sitename_uppercase variable. We will also create a string literal with “”  and then call the toUpperCase() function from that string literal which will return the uppercase “POFTUT.COM”.

toUpperCase() Examples

toUpperCase() Examples

UpperCase Only First Letter Of The Word

We can also make the first letter of the given word or string uppercase. We will use the charAt() function in order to specify the first letter which index is 0 and then we will use slice() function which will return the remaining string apart from the first letter. In the following example, we will make the string “”  first letter uppercase which will look like “”.

Leave a Reply

Your email address will not be published. Required fields are marked *