freeCodeCamp Challenge Guide: Understand String Immutability

freeCodeCamp Challenge Guide: Understand String Immutability
0.0 0

#1

In Javascript, String values are immutable, which means that they cannot be altered once created.

Example

var myStr = "Bob";
myStr[0] = "J";

Would not work, the only way would be:

var myStr = "Bob";
myStr = "Job";

#2

I am still confused on how exactly to do this


#3

// Setup
var myStr = “Jello World”;

// Only change code below this line

var myStr = “Hello World”; // Fix Me


#4

I keep getting an TypeError: 0 is read only message when I tried that. Still not sure if it’s cause I’m missing something or its an error on their side.


#5

any can fix this problem ? I still have this case


#6

I ran into the TypeError as well when I copies “ello World” and pasted it next to the H. However, when I cleared my changes and manually typed it out it worked fine. I hope this helps.


#8

Nothing above worked for me, it’s strange. So I just did like this:

// Setup
var myStr = “Jello World”;
// Only change code below this line
myStr =“Hello World”;
myStr[0];

Weird :sweat_smile:, I know (it also had a red underline) but it worked. :point_up_2:
So my question is: How can I improve it?


#9
// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me

/////////////////////////////////////////////////////////////////////////////////

// Setup
var myStr = "Jello World";

// Only change code below this line

myStr = "Hello World"; // Fix Me

#10

The instructions are hard to understand. You need to change the bottom code to correct the mistake from “Jello World” to “Hello World”


#11

// Setup
var myStr = “Jello World”;

// Only change code below this line
myStr = ‘Hello World’;
myStr[0] ;


#12

Just delete = “H” in the end of the code and left only myStr[0];


#13

that works but i think it’s confusing ppl bc the instructions read only change code below …
change code below line to…

var myStr = “Hello World”;
** myStr[0];**


#14

i used a console.log (myStr[0]);


#15

I got: var myStr = “Hello World”;