C
cjl
Hey all:
I need to get some user input which will be a six digit number. I will
split it into two character pairs. Each pair will need to be "looked
up", for example:
if firstPair == '01' then variable = "Monkey";
else if firstPair == '02' then variable = "Chicken";
etc..
So I think I could do this with if / else statements chained together,
and I think I could do this with a switch statement.
I remember someone showing a way to do this with a hash, but I can't
find it anywhere.
Is there a javascript idiom that is more elegant for this problem than
if / else or switch?
-CJL
I need to get some user input which will be a six digit number. I will
split it into two character pairs. Each pair will need to be "looked
up", for example:
if firstPair == '01' then variable = "Monkey";
else if firstPair == '02' then variable = "Chicken";
etc..
So I think I could do this with if / else statements chained together,
and I think I could do this with a switch statement.
I remember someone showing a way to do this with a hash, but I can't
find it anywhere.
Is there a javascript idiom that is more elegant for this problem than
if / else or switch?
-CJL