Carl Robles
Forum Veteran
changing string casing javascript
toUpperCase() and toLowerCase() methods. Here's an example:let myString = "Hello World!";
let upperCaseString = myString.toUpperCase(); // "HELLO WORLD!"
let lowerCaseString = myString.toLowerCase(); // "hello world!"
toUpperCase() method will convert all characters in the string to uppercase, while the toLowerCase() method will convert all characters in the string to lowercase.charAt() and substring() methods, and then combining them with the toUpperCase() or toLowerCase() method. Here's an example:let myString = "Hello World!";
let firstLetterUpperCase = myString.charAt(0).toUpperCase() + myString.substring(1); // "Hello World!"
let firstLetterLowerCase = myString.charAt(0).toLowerCase() + myString.substring(1); // "hello World!"
charAt() method to get the first character of the string, and then combining it with the rest of the string using the substring() method. We're then using the toUpperCase() and toLowerCase() methods to change the casing of the first character.