Skip to content

Instantly share code, notes, and snippets.

@brettvaida
Last active February 25, 2022 18:14
Show Gist options
  • Save brettvaida/beb0487f86972b6ed9d056b80455a263 to your computer and use it in GitHub Desktop.
Save brettvaida/beb0487f86972b6ed9d056b80455a263 to your computer and use it in GitHub Desktop.
Kelvin to Fahrenheit calculator
// Prompting the user to enter today's Kelvin temperature
const kelvin = prompt('What is the Kelvin temperature today?');
// Celsius is 273 degrees less than Kelvin
const celsius = kelvin - 273;
// Calculating Fahrenheit temperature to the nearest integer
let fahrenheit = Math.floor(celsius * (9/5) + 32);
// Displaying the temperature using string interpolation
console.log(`The temperature is ${fahrenheit} degrees fahrenheit.`)
@Aidan-The-Dev
Copy link

It just returns NaN for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment