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: Klaus Johannes Rusch <KlausRusch@atmedia.net>
Date: Wed Aug 10 2005 - 12:24:10 CEST

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];

-- 
Klaus Johannes Rusch
KlausRusch@atmedia.net
http://www.atmedia.net/KlausRusch/
Received on Mon Oct 24 02:13:59 2005