Skip to content

Instantly share code, notes, and snippets.

@jloescher
Created February 5, 2021 22:58
Show Gist options
  • Save jloescher/11cc7a7689c51ce18fe883ae5dfcbd45 to your computer and use it in GitHub Desktop.
Save jloescher/11cc7a7689c51ce18fe883ae5dfcbd45 to your computer and use it in GitHub Desktop.
Temperature unit conversion JS
// Holds the constant value of the kelvin tempature
const kelvin = 0;
// Convert kelvin to celsius
const celsius = kelvin - 273;
// Convert celsius to fahrenheit
let fahrenheit = celsius * (9/5) + 32;
// Rount the value from the quation to the nearest whole number.
fahrenheit = Math.floor(fahrenheit);
console.log(`The temperature is ${fahrenheit} degrees Fahrenheit.`);
// Convert celsius to newtons
let newton = celsius * (33/100);
newton = Math.floor(newton);
console.log(newton)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment