Math expressions

I have the following piece of code part os a testing my knowledge… I am struggling a bit:

let kelvin = 293;
// convert the value of kelvin to celsius
let celsius = kelvin -= 273;
// convert celsius to fahrenheit
let fahrenheit = (celsius * (9/5)) + 32;
// round number do whole number
fahrenheit = Math.floor();
console.log(`The temperature in ${fahrenheit} Fahrenheit.`);

Not sure what could be wrong…

.floor() expects the number it is suppose round down/floor as argument

see documentation:

In the questionaire says :slightly_frowning_face:

Use the .floor() method from the built-in Math object to round down the Fahrenheit temperature. Save the result to the fahrenheit variable.

If I comment the line:

fahrenheit = Math.floor();

I got a correct answer…

True, but .floor() doesn’t magically know which number it has to round down/floor. How is .floor() suppose to know?

As well as what @stetim94 said, when you assign a variable to the value stored in another, you don’t need to put let var1 = var2 -= 4, as you have here:

If you want to set celsius to kelvin -273, then you would do just that:

let celsius = kelvin - 273

Notice how you don’t need the -=?

thank you all, after some research I found the right syntax for my code:

fahrenheit = Math.floor(fahrenheit);

that worked fine. Thank you all :wink: :wink: :wink: :wink: