Last active
February 25, 2022 18:14
-
-
Save brettvaida/beb0487f86972b6ed9d056b80455a263 to your computer and use it in GitHub Desktop.
Kelvin to Fahrenheit calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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.`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It just returns NaN for me