I am new to this forum so I hope that I am posting this question in the correct place?
I just completed Kelvin-Weather and have a question about the difference between “let” and “const”
The exercise tells us to use “const” for the Kelvin temperature and then “const” again for the Celsius temperature. Further down in the exercise they get us to calculate the temperature in Newtons but this time when I used “const” with Newton I got an error message:
newton = Math.floor(newton);
TypeError: Assignment to constant variable.
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
When I changed “const newton = celsius *(33/100)” to “let newton = celsius *(33/100)” the code worked. I don’t understand why we could use const at the beginning of the exercise with Kelvin and Fahrenheit but that it had to change to “let” with Newton. I has something to do with the Math.floor command… I just don’t understand this.
The code is below: