Created
July 25, 2012 13:02
-
-
Save stevekinney/3176064 to your computer and use it in GitHub Desktop.
Function Example: Convert Fahrenheit to Celsius
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good