Difference between const and let

Tell us what’s happening:
Hello, I just did not understand the real difference between const and let

Your code so far


function printManyTimes(str) {
"use strict";

// Only change code below this line

const SENTENCE = str + " is cool!";
for (let i = 0; i < str.length; i+=2) {
  console.log(SENTENCE);
}

// Only change code above this line

}
printManyTimes("freeCodeCamp");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0.

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

Link to the challenge:

const variables cannot be reassigned.

const animal = dog
animal = cat //throws an error
console.log(animal) //prints dog

let variables can be reassigned

let animal = dog
animal = cat
console.log(animal)//prints cat
2 Likes

For more insights, you can read this FCC article