 # [Kelvin weather] Can't pin point the problem, it seems identical to other people code, but doesn't work

Hello,
I’m terribly new so sorry if I picked wrong format and you can let me know if I should ask questions next time differently.
The thing is that I seemed to write a code and it didn’t work, checked hints and it seems to be exactly as I have written it. Checked forums and found exactly the same codes that work, but mine for some reason don’t. I could copy other peoples code, but I want to learn for myself, why my code doesn’t work, am I missing something?

//Today’s forcast is 293 Kelvin.
const kelvin = 293;
//To get celcius, subract 273 from kelvin.
const celsius = kelvin - 273;
//Calculate fahreinheit you need formula.
let fahreinheit = celcius * (9/5) + 32;
//To round up number
fahreinheit = Math.floor(fahreinheit);
console.log(`The temperature is \${fahreinheit} degrees Fahreinheit.`);
const newton = Celsius * (33/100);
newton = Math.floor(newton);
console.log(`The temperature is \${newton} degrees Newton.`);

hi. double check your console.log() statement. if you use {} to access variables you should wrap your code in backtick.

I did use (`) for some reason when it was coppied into a text, they were removed.
The problem starts from this line: let fahreinheit = celcius * (9/5) + 32; (at least as far as I managed to understand by removing one line at the time to see when the code works)

Hello, and welcome to the forums!

I notice a couple issues:

1. You use 3 different spellings and/or letter casing for ‘celsius’, so they all are treated like different variables: `celsius`, `celcius`, and `Celsius`. Need to be consistent with one of them
2. You declare `newton` as a `const`, but then you try to change the value of it. You could either use `let` instead of `const` so JavaScript won’t be angry about the value changing, or you could integrate the call to `Math.floor()` on the line you are setting the value
2 Likes

Thank you so much. I thought that was some stupid misspelling error on my part ^^

2 Likes

I’m having an error with my console.log() print out from my Newton conversion. I used the Math.floor() method exactly the same way as I did for the Fahrenheit conversion, but I am still getting decimal places in my Newton conversion (6.6000000000000005). Any idea as to why this is happening?

//Today’s temperature is 293 kelvin
const kelvin = 293;
//celsius is found by subtracting 273 from the kelvin temperature
let celsius = kelvin - 273;
//this is the equation that converts celsius to fahrenheit
let fahrenheit = celsius * (9/5) + 32;
//This line of code rounds the number down to a whole number
fahrenheit = Math.floor(fahrenheit);
console.log(`The temperature is \${fahrenheit} degrees Fahrenheit`);
//convert to newton
let newton = celsius * (33/100);
//Round down
Newtown = Math.floor(newton);
console.log(`The Temperature is \${newton} degrees Newton.`);

You used Math.floor() but you saved it to a different variable (similar name but JavaScript still sees it as different), and then you printed out the original value:

1 Like