You can reuse code: Define the code once, and use it many times. You can use the same code many times with different arguments, to produce different results. For example, this function can be used everytime you want to convert Fahrenheit to Celsius:
function toCelsius(fahrenheit) {
return (5/9) * (fahrenheit-32);
}
document.getElementById("demo").innerHTML = toCelsius(77);