JavaScript Code

String toUpperCase() in JavaScript


String toUpperCase()

In JavaScript, String.toUpperCase() method is used to convert the given string to upper case string.

Syntax

str.toUpperCase()

where

  • str is a string.

toUpperCase() method makes a copy of the given string, converts the lowercase characters to uppercase characters, and returns the resulting string.

The value in the string variable str is unmodified.

Example

1. In the following program, we convert the value in string txt to uppercase.

let txt = 'Apple Banana';
let output = txt.toUpperCase();
console.log(output);
//output : APPLE BANANA

Copyright @2022