
Join the Conversation!
Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.
In this lesson, you'll learn about changing the case of strings in JavaScript, using simple methods to convert text to uppercase or lowercase.
What is the case? You've definitely heard about uppercase and lowercase letters. In JavaScript, we have two straightforward methods for changing the character case:
These methods allow you to convert a string to all lowercase or all uppercase letters, respectively.
Let's see how these methods work in practice:
const mixedCaseString = 'Hello! How are you, James?';
console.log(mixedCaseString.toLowerCase()); // "hello! how are you, james?"
console.log(mixedCaseString.toUpperCase()); // "HELLO! HOW ARE YOU, JAMES?"
Notice how we have parentheses on these methods. That's because they are functions, more precisely methods, that we call on a string. These methods do not modify the original string; instead, they return a new string with the desired case transformation.
Now that you've learned how to change the case of a string, let's explore more useful string methods! 😊
"Please login to view comments"
Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.