diff --git a/curriculum/challenges/english/blocks/lecture-working-with-string-formatting-methods/67326c1fdaf9c0c5ad1a2589.md b/curriculum/challenges/english/blocks/lecture-working-with-string-formatting-methods/67326c1fdaf9c0c5ad1a2589.md index 7e5ffbea90e..6ab78288b9f 100644 --- a/curriculum/challenges/english/blocks/lecture-working-with-string-formatting-methods/67326c1fdaf9c0c5ad1a2589.md +++ b/curriculum/challenges/english/blocks/lecture-working-with-string-formatting-methods/67326c1fdaf9c0c5ad1a2589.md @@ -5,7 +5,7 @@ challengeType: 19 dashedName: how-can-you-change-the-casing-for-a-string --- -# --description-- +# --interactive-- When working with strings in JavaScript, there are many situations where you might need to adjust the case of the text, such as transforming all letters to uppercase for a heading or converting text to lowercase for uniformity. @@ -15,12 +15,16 @@ The `toUpperCase()` method converts all the characters to uppercase letters and Let's see an example: +:::interactive_editor + ```js let greeting = "Hello, World!"; let uppercaseGreeting = greeting.toUpperCase(); -console.log(uppercaseGreeting); // Output: "HELLO, WORLD!" +console.log(uppercaseGreeting); // "HELLO, WORLD!" ``` +::: + In this code, the `toUpperCase()` method transforms the entire string into uppercase letters. The original string remains unchanged because `toUpperCase()` returns a new string, rather than modifying the original one. @@ -29,12 +33,16 @@ On the flip side, the `toLowerCase()` method converts all characters in a string Let's look at an example: +:::interactive_editor + ```js let shout = "I AM LEARNING JAVASCRIPT!"; let lowercaseShout = shout.toLowerCase(); -console.log(lowercaseShout); // Output: "i am learning javascript!" +console.log(lowercaseShout); // "i am learning javascript!" ``` +::: + The `toLowerCase()` method converts all characters to lowercase, making the string less aggressive, while leaving the original string unchanged. In summary, the `toUpperCase()` and `toLowerCase()` methods in JavaScript are powerful tools for transforming strings into all uppercase or lowercase letters.