# Kelvin Weather. Math.Floor not working and type erorrs

// Variables

const kelvin = 0;

const celsius = kelvin - 273;

// Kelvin to Celsius

const fahrenheit = celsius * (9 / 5) + 32

// Fahrenheit to Celsius

fahrenheit == Math.floor(fahrenheit)

//fahrenheit round

console.log(`The temperature is \${fahrenheit} degrees Fahrenheit.`)

console.log(kelvin);

console.log(celsius);

console.log(fahrenheit);

//Checks

const newton = celsius * (33/100);

newton == Math.floor(newton);

console.log(newton)

log

Output-only Terminal

Output:

The temperature is -459.40000000000003 degrees Fahrenheit. 0 -273 -459.40000000000003 -90.09
Version 1
// Variables

const kelvin = 0;

const celsius = kelvin - 273;

// Kelvin to Celsius

const fahrenheit = celsius * (9 / 5) + 32

// Fahrenheit to Celsius

fahrenheit = Math.floor(fahrenheit)

//fahrenheit round

console.log(`The temperature is \${fahrenheit} degrees Fahrenheit.`)

console.log(kelvin);

console.log(celsius);

console.log(fahrenheit);

//Checks

const newton = celsius * (33/100);

newton = Math.floor(newton);

console.log(newton)

log
/home/ccuser/workspace/learn-javascript-intro-kelvin-weather/app.js:9
fahrenheit = Math.floor(fahrenheit)
^

TypeError: Assignment to constant variable.
at Object. (/home/ccuser/workspace/learn-javascript-intro-kelvin-weather/app.js:9:12)
at Module._compile (module.js:571:32)
at Object.Module._extensionsâ€¦js (module.js:580:10)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
at bootstrap_node.js:542:3

Version 2

I do not understand what is going on I checked it was the answer in the hints

If you declare a variable using `const`, then you canâ€™t change the value assigned to that variable.

You had `const fahrenheit = celsius * (9 / 5) + 32`
so you canâ€™t assign a number to `fahrenheit` afterward using `fahrenheit =`

If you change the `const` to `let`, then you can change the value of the variable.

Alternatively, you could do
`const fahrenheit = Math.floor( celsius * (9 / 5) + 32 );`
to get everything done on the same line, so that you donâ€™t need to change the value of `fahrenheit`.

2 Likes