Kelvin Weather Project

Hey guys! The Math.floor() is NOT rounding down the number in the console. What do you think could be the issue? Here’s my code:

//Temperture in Kelvin

const kelvin = 0

//Temperture in Celsius

const celsius = kelvin - 273

//Temperture in Fahrenheit

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

//Fahrenheit rounded down to nearest whole number

Math.floor(fahrenheit)

console.log(The temperature is ${fahrenheit} degrees Fahrenhiet.)

My best guess is that Math.floor returns a value rather than modify farenheit in-place so you’ll probably need to either reassign or use the return directly.

1 Like

Hi !

Remember to add the quotation marks and rewrite the same variable as “fahrenheit”.

// Value of Kelvin temperature

const kelvin = 283;

// Convertion of Kelvin to Celsies.

let celsius = kelvin - 273;

console.log(celsius);

// Convert from Celsius to Fahrenheit

let fahrenheit = (celsius * (9/5)) + 32;

// Round up to integer number

fahrenheit = Math.floor(fahrenheit);

// Converto from Celsius to Newton

let newton = (celsius * 33/100);

newton = Math.floor(newton);

// Output for the Fahrenheit temperature.

console.log(The temperature is ${fahrenheit} degress Fahrenheit)

// Output for the Celsius temperature.

console.log(The temperature is ${celsius} degress Celsius);

// Output for the Kelvin temperature.

console.log(The temperature is ${kelvin} degress Kelvin);

// Output for the Newton temperature.

console.log(The temperature is ${newton} degress Newton);

1 Like

I see where I made the mistake. Thank you for your help!