JavaScript Code


How to convert string to uppercase using JavaScript?


Convert string to uppercase

Given a string, convert the string to uppercase using JavaScript.

Solution

To convert a given string to uppercase using JavaScript, call toUpperCase() method on the string. The method returns a new string with the characters in the given string converted to uppercase.

Program

1. Given a string in str. Convert the string str to uppercase.

let str = 'Hello World';
let output = str.toUpperCase();
console.log(output);