Re: Select 1 value from multiple...
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Select 1 value from multiple...

From: Noozer <dont.spam@me.here>
Date: Wed Aug 10 2005 - 12:47:51 CEST

"Klaus Johannes Rusch" <KlausRusch@atmedia.net> wrote in message
news:3lu2u8F13p5d9U1@individual.net...
> Noozer wrote:
> > I want to return one of several values, based on the value of a
variable.
> >
> > Is there a compact way to write this? Something like:
> >
> > var J=5;
> > var K= {"One","Two","Three","Four","Five","Six"} [J] ;
> >
> >
> > ... so K would hold "Five" in this case.
>
> var J=5;
> var K= (new Array("One","Two","Three","Four","Five","Six"))[J-1];

Just wondering if there was a way to combine it on one line... No problem.
This works.
Received on Mon Oct 24 02:14:00 2005