PrettyFlyForAFatGuy,

why wouldn’t you just convert inline? (Number(input_val) === 2)

Converting would mean you could use a switch statement with your example rather than an if else ladder


<span style="color:#323232;">switch(Number(input_val)) {
</span><span style="color:#323232;">  case 1:
</span><span style="color:#323232;">    doTheFirstThing();
</span><span style="color:#323232;">  break;
</span><span style="color:#323232;">  case 2:
</span><span style="color:#323232;">    doTheSecondThing();
</span><span style="color:#323232;">  break;
</span><span style="color:#323232;">  case 3:
</span><span style="color:#323232;">    doTheThirdThing();
</span><span style="color:#323232;">  break;
</span><span style="color:#323232;">}
</span>
  • All
  • Subscribed
  • Moderated
  • Favorites
  • programmerhumor@lemmy.ml
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines