"Let" Variable Value - Is It Immutable?

One of the previous tasks says that you can’t redefine a variable once you make it “let” something. But here we are redefining the variable value after “let”

// Setup
let myStr = "Jello World";

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

Challenge: Basic JavaScript - Understand String Immutability

Link to the challenge:

You cn change the contents of a variable declared with let, you just can’t redeclare the variable with a new let myVar statement

Thanks. What is the reason for let operating in this way

You often need to change the value stored in a variable. Redeclaring a variable in the same scope is typically a mistake. JS permits the first while preventing the second if you use let.

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