Skip to content

Instantly share code, notes, and snippets.

@sayyedhammadali
Created October 2, 2021 22:07
Show Gist options
  • Save sayyedhammadali/e9f254cfb9ee8753e926432777aee1c2 to your computer and use it in GitHub Desktop.
Save sayyedhammadali/e9f254cfb9ee8753e926432777aee1c2 to your computer and use it in GitHub Desktop.
Convert Fahrenheit / Celsius
const celsiusToFahrenheit = (celsius) => celsius * 9/5 + 32;
const fahrenheitToCelsius = (fahrenheit) => (fahrenheit - 32) * 5/9;
// Examples
celsiusToFahrenheit(15); // 59
celsiusToFahrenheit(0); // 32
celsiusToFahrenheit(-20); // -4
fahrenheitToCelsius(59); // 15
fahrenheitToCelsius(32); // 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment