Basic JavaScript: Word Blanks

Basic JavaScript: Word Blanks
0.0 0

#1

Tell us what’s happening: Please why do I have to include my Addition mark inside my functions parameters strings twice? I don’t get it. Please clear me.

Your code so far


// Setup
var myStr = "Jello World";

// Only change code below this line

var myStr = "Jello World"; // Fix Me
myStr = "Hello World";
myStr[0] = "H";



Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/understand-string-immutability/


#2

Like the instruction says string values are immutable. So your last line of code

myStr[0] = "H"; is invalid.

And myStr has already been declared and intialized on the setup. So you can just directly assign

“Hello World” into myStr variable which is what you already have 2nd line from the bottom.

Here is the solution if you still can’t figure it out.

myStr = “Hello World”;


#3

Look at the example. They showed you the only way to change myStr would be to assign it with a new string (see below).

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

#4

Thanks guys. Just that I don’t know how to use this Forum yet. I sorted my string immutability already.
What I needed is “Please why do I have to include my Addition mark inside my functions parameters strings twice? I don’t get it. Please clear me”_