How to Convert Strings to Uppercase in JavaScript

How to Convert Strings to Uppercase in JavaScript

JavaScript is a popular programming language, which is usually used for web development. With the help of JavaScript, various types of tasks can be easily done. In today's blog, I will discuss in detail with code how to convert any lowercase letter to uppercase.

 

Problem – Converting lowercase letters to uppercase letters?

 

Code


// Original string
let str = "I am now trying to learn javascript";

// Converting all characters to uppercase
let upperStr = str.toUpperCase();

// Logging the converted string to the console
console.log(upperStr);

// Output
I AM NOW TRYING TO LEARN JAVASCRIPT


Explanation of code

  • First, I created a string, which contains some lowercase letters.
  • The toUpperCase() method converts all the lowercase letters in the string to uppercase letters.
  • Finally, the converted string is shown in the console through console.log().

 

Bookmark the website! If you like the post and don't forget to share the post so that your friends don't miss it. Be sure to like and comment so that we can constantly come up with new problems as well as solutions. And if you also have any coding-related problems, let us know in the comment box and we will try to solve them, InshaAllah.


About the author

Ahshan Habib
Hello! I am Ahshan Habib. I am a MERN Stack web developer. Blogging is my hobby and I would like to share my knowledge with everyone. Here I will share every day about education, technology, and Programming. So stay with us and share my page on your…

Post a Comment