Advertisement
makispaiktis

Codecademy - 7th Exercise (Temperature Converts)

Sep 26th, 2019 (edited)
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Constant temperature
  2. const kelvin = 293;
  3. // T(K) = T(C) + 273
  4. let celsius = kelvin - 273;
  5. // T(F) = (9/5) * T(C) + 32
  6. let fahrenheit = 1.8 * celsius + 32;
  7. // Round "donw" the Fahrenheit temperature
  8. fahrenheit = Math.floor(fahrenheit);
  9. // Display
  10. console.log("Kelvin:     " + kelvin);
  11. console.log("Celsius:    " + celsius);
  12. console.log(`Fahrenheit: ${fahrenheit} `);
  13. // Newton Scale for temperature
  14. let newton = 0.33 * celsius;
  15. newton = Math.floor(newton);
  16. console.log("Newton:     " + newton);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement