How do I overcome - TypeError: Cannot assign to read only property ‘0’ of string ‘Jello World’
Your code so far
// Setup
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
// Setup
var myStr = "Jello World";
// Only change code below this line
myStr[0] = "Hello World"; // 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/96.0.4664.110 Safari/537.36
Interestly enough, you do have the correct answer in one of these lines of code but I don’t think you realize which one of these lines of code is the correct answer
Let’s take a close look at the example code again so we can better understand the concept.
Here is the lesson code
let myStr = "Bob";
myStr = "Job";
We have a variable called myStr and assigned to it is the name "Bob"
In the second line of code, we are now assigning the word "Job" to the myStr variable.
The same concept applies to the challenge.
We have a variable called let myStr = "Jello World";
But we want to assign a new string to myStr so it says "Hello World"