mardi 30 juin 2020

Check if number is within the range in JavaScript [duplicate]

I am trying to find whether the value of the wind direction is within the range for each output. For example, to output "27" I want the metar.wind.degrees to be between 180 and 360 and for an output of "09" I want the metar.wind.degrees to be between 0 and 180.

I would really appreciate any help I could get with this as I've spent a long time truing to figure it out. Here is the code I have so far:

        document.getElementById('wind_direction').innerText = metar.wind.degrees;
        if (180 < metar.wind.degrees < 360) { 
            runway = "27";
        }
        else if (0 < metar.wind.degrees < 180) {
            runway = "09";
        }
        else {
            runway = "Winds allow for either runway.";
        } } 
        document.getElementById("runway").innerHTML = runway;
      }

Aucun commentaire:

Enregistrer un commentaire