Skip to content

Instantly share code, notes, and snippets.

@stevekinney
Created July 25, 2012 13:02
Show Gist options
  • Save stevekinney/3176064 to your computer and use it in GitHub Desktop.
Save stevekinney/3176064 to your computer and use it in GitHub Desktop.
Function Example: Convert Fahrenheit to Celsius
function convertFahrenheitToCelsius(temperature) {
// Take whatever temperature the function is handed, do some math and return it.
return (temperature - 32) * (5/9)
}
// Prompt the user and store whatever they say in a variable.
var theirInput = prompt("Enter in a Fahrenheit temperature & I'll convert it to Celsius");
// Run their number through the function and store it in a variable named result.
var result = convertFahrenheitToCelsius(theirInput);
// Alert the user to the result.
alert(result);
Copy link

ghost commented Aug 12, 2021

good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment