Files
freecodecamp--freecodecamp/curriculum/challenges/english/blocks/basic-javascript/56533eb9ac21ba0edf2244ba.md
T
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.3 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
56533eb9ac21ba0edf2244ba Understand String Immutability 1 18331 understand-string-immutability

--description--

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

For example, the following code will produce an error because the letter B in the string Bob cannot be changed to the letter J:

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

Note that this does not mean that myStr could not be re-assigned. The only way to change myStr would be to assign it with a new value, like this:

let myStr = "Bob";
myStr = "Job";

--instructions--

Correct the assignment to myStr so it contains the string value of Hello World using the approach shown in the example above.

--hints--

myStr should have a value of the string Hello World.

assert(myStr === 'Hello World');

You should not change the code above the specified comment.

assert(/myStr = "Jello World"/.test(__helpers.removeJSComments(code)));

--seed--

--seed-contents--

// Setup
let myStr = "Jello World";

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

--solutions--

let myStr = "Jello World";
myStr = "Hello World";