// Setup
let myStr = "Jello World";
// Only change code below this line
myStr[0] = "H"; // Change this line
// Only change code above this line
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.686 YaBrowser/23.9.5.686 Yowser/2.5 Safari/537.36
Challenge Information:
Basic JavaScript - Understand String Immutability
Why doesn’t my option work? Of course, I always knew that a Java script is impossible to understand how it works, but here you can’t understand the instructions, what exactly do they want to see from the students?
let myStr = "Jello World";
// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Change this line
// Only change code above this line
The challenge in this one wants you to correct the assignment from using index based assignment like this:
myStr[0] = "J"
To this:
Mod edit: Removed Solution
You can see in the challenge, there’s a comment that says [Change this line]. You only need to change that single line and nothing else.
The challenge wants to make you get the point: You can’t change a single letter in a string after it has been created using the square brackets notation like [0], [1], [2] which you usually use when changing the value of an array or an object.
I think you misunderstand the challenge because it’s text-based instructions?
I hope that clear things up. Let me know if you have any more questions.
myStr = "Hello World";
myStr[0] = "H"; // Change this line
You were supposed to change the second line, but instead you added the first line. The directions didnt say to delete that line because you were supposed to change it. Instead you added a new line which forced you to remove the line to pass