DEV Community

Discussion on: What is the difference between 'Var' and 'Let' ?

Collapse
 
tobiassn profile image
Tobias SN • Edited

The reason you couldn’t assign the let variable is because you were declaring it at the same time, which you had already done. After a variable has been declared, just do a = 4 instead of let a = 4. Same goes for var, which you shouldn’t be using anyway.

However, if you do want a variable that can’t be re-assigned after the first time, use const instead of let.