Hi, I just started learning Javascript and I didn’t understand the output of this code.
I expected it to be “freeCodeCamp is cool” but instead it prints “freeCodeCamp is awesome” twice.
1- I thought let keyword makes the variable unchangeable, why did the line after that changed it?
2- Why does it print the output two times when I run it?
Your code so far
const FCC = "freeCodeCamp"; // Change this line
let fact = "is cool!"; // Change this line
fact = "is awesome!";
console.log(FCC, fact); // Change this line
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15
Challenge: Declare a Read-Only Variable with the const Keyword
That’s sort of a quirk with the system. It is printing out once because you have a console.log in your code and then printing out again when the code is actually tested. Nothing to worry about.