Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
cursed-switch.js
var key = true;
switch ( key ){ // Earth
case ( altitude <= 36152. ): // Altitude is in feet // Troposphere
temperature = 518.6 - 3.56 * ( altitude / 1000. );
break;
case ( altitude >= 36152. && altitude <= 82345. ): // Stratosphere
temperature = 389.98;
break;
case ( altitude >= 82345. && altitude <= 155348. ):
temperature = parseFloat( 389.98 ) + parseFloat( 1.645 ) * parseFloat( altitude - 82345. ) / 1000.;
break;
case ( altitude >= 155348. && altitude <= 175346. ):
temperature = 508.788;
break;
case ( altitude >= 175346. && altitude <= 262448. ):
temperature = 508.788 - 2.46888 * ( altitude - 175346. ) / 1000.;
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment