FreeCodeCamp.com - Basic JavaSript - Understand String Immutability

Link to FreeCodeCamp

In JavaScript, String values are immutable, which means that they cannot be altered once created.
For example, the following code:
var myStr = "Bob";
myStr[0] = "J";
cannot change the value of myStr to "Job", because the contents of myStr cannot be altered. Note that this does not mean that myStr cannot be changed, just that the individual characters of a string literal cannot be changed. The only way to change myStr would be to assign it with a new string, like this:
var myStr = "Bob";
myStr = "Job";

Instructions

Correct the assignment to myStr to achieve the desired effect.

Sollution

// Setup
var myStr = "Jello World";

// Only change code below this line

myStr = "Hello World";

Komentáře

Populární příspěvky z tohoto blogu

FreeCodeCamp.com - Basic JavaSript - Passing Values to Functions with Arguments

FreeCodeCamp.com - Basic JavaSript - Word Blanks