CONSOLE - Declare a Read-Only Variable with the const Keyword

Tell us what’s happening:
Why the console log prints
freeCodeCamp is awesome!
and not
freeCodeCamp is cool!

Your code so far

// Only change code below this line
const FCC = "freeCodeCamp";
let fact = "is cool!";
// Only change code above this line

fact = "is awesome!";
console.log(FCC, fact);

Your browser information:

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

Challenge: Declare a Read-Only Variable with the const Keyword

Link to the challenge:

This line changes the value stored in fact. The console.log uses the most recent value that the variable was set to before it is called.

The variable FCC is declared as read-only but the ‘fact’ variable wasn’t. That’s why you can change it

1 Like

ok, but… fact its defined with let
sigo confundida

You can change a variable declared with let. You can’t change a variable declared with const.

1 Like

so, you can do this
let fact = “is cool!”;
fact = “is awesome!”;

But not this
let fact = “is cool!”;
let fact = “is awesome!”;

Yep. Redeclaration is not allowed with let or const.

1 Like

gracias por tu ayuda!

1 Like

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