Skip to content

Instantly share code, notes, and snippets.

@bvibber
Created December 29, 2021 01:13
Show Gist options
  • Save bvibber/25cdb554edeff6a70e429b67de3038bd to your computer and use it in GitHub Desktop.
Save bvibber/25cdb554edeff6a70e429b67de3038bd to your computer and use it in GitHub Desktop.
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