Changing strings that were already created

Tell us what’s happening:
Describe your issue in detail here.

Your code so far


// Setup
let myStr = "Jello World";

// Only change code below this line
myStr[0] = "Hello World"; // Change this line
// Only change code above this line

As you can see my code so far, I’ve watched the video and the get hint and am still unable to solve this. Can someone tell me what I am doing wrong please? It’s telling me that type [0] is read only.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0

Challenge: Understand String Immutability

Link to the challenge:

It looks like you’ve mimicked the example that it says does not work.

myStr[0] is equal the letter “J”, which is part of the string. You cant change part of a string. Its not an array where you target an element and change its value. You need to give new value for the whole string
PS: read lesson explanation carefully

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.