The toUpperCase() method in JavaScript is used to convert all the characters in a string to uppercase letters.
Syntax: string.toUpperCase()
- string: The string you want to convert to uppercase.
Example:
let str = "hello, world!";
let upperCaseStr = str.toUpperCase();
console.log(upperCaseStr); // Output: HELLO, WORLD!
Explanation:
- We have a string str containing the text "hello, world!".
- We use toUpperCase() to convert all the characters in the string to uppercase.
- The resulting string, "HELLO, WORLD!", is stored in the variable upperCaseStr and logged to the console.
Code Compiler Link: https://app.singhteekam.in/codecompiler/