mercredi 8 juillet 2015

Shorter way to write Jquery If Statement with multiple options for the "IF"

Is there an easier / shorter way with Jquery for writing an if statement like this:

if(number === "0" ) { degrees = "-160"; }
if(number === "1" ) { degrees = "-158"; }
if(number === "2" ) { degrees = "-156"; }
if(number === "3" ) { degrees = "-154"; }
if(number === "4" ) { degrees = "-152"; }
if(number === "5" ) { degrees = "-150"; }
if(number === "6" ) { degrees = "-148"; }
if(number === "7" ) { degrees = "-146"; }
if(number === "8" ) { degrees = "-144"; }
if(number === "9" ) { degrees = "-142"; }
if(number === "10") { degrees = "-140"; }

The number variable is just an input field where the user enters a number from 0 - 10.

Thank you!

Aucun commentaire:

Enregistrer un commentaire