Javascript: Solve the equation system

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(){
        //Get Temp
        var T = parseInt($('#val1').val());
        //Get RH
        var RH = parseInt($('#val2').val());
        //Get es and ex
        var es = 6.112*Math.exp(17.76*T/(T+243.5));
        var ex = (RH*es)/100;
        //Calculate Dew Point
        var Tdp = (243.5*Math.log(ex/6.112))/(17.67-Math.log(ex/6.112));
        $('#output').append("<p>Dew Point"+Tdp+"</p>");

    });
+3
source share
1 answer

FYI , , . , .

, , , , , . , , , , , DWIM, , . ( , , , .)

+1

All Articles