I am making a dew point calculator using the approximate approximation on Wikipedia.
I want to be able to calculate the dew point if the user enters any two variables.
Is there an easy way to do this, and not have many if statements?
More specifically: what if I wanted to use the temperature of a wet thermometer instead of relative humidity? Should I create a new function or use if-statement to exclude a set of variables?
I am currently using temperature and relative humidity:
$('#calculate').click(function(){
var T = parseInt($('#val1').val());
var RH = parseInt($('#val2').val());
var es = 6.112*Math.exp(17.76*T/(T+243.5));
var ex = (RH*es)/100;
var Tdp = (243.5*Math.log(ex/6.112))/(17.67-Math.log(ex/6.112));
$('#output').append("<p>Dew Point"+Tdp+"</p>");
});
source
share