Skip to content

Instantly share code, notes, and snippets.

@robertbenjamin
Created September 17, 2015 17:58
Show Gist options
  • Select an option

  • Save robertbenjamin/e7d44edfc76ee6212372 to your computer and use it in GitHub Desktop.

Select an option

Save robertbenjamin/e7d44edfc76ee6212372 to your computer and use it in GitHub Desktop.
function convert(temp) {
// This takes the number you gave it (temp), converts it to celcius, then stores it in the celsius variable
celsius = (temp - 32) / 1.8;
// This prints the fahrenheit degree you gave it, and what the same degree is in celsius
console.log(temp + " degrees Fahrenheit is " + celsius + " degrees in Celsius!")
return celsius
}
// Now, I run the function above and put in the fahrenheit degress I want to convert
convert(32) // This returns "32 degrees Fahrenheit is 0 degrees in Celsius!"
convert(100) // This returns "100 degrees Fahrenheit is 37.77777777777778 degrees in Celsius!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment