I would like to pass the variable to the key of my variable monthHashhere:
var monthHash = new Array();
monthHash["JAN"] = "Jan";
monthHash["FEB"] = "Feb";
...
monthHash["NOV"] = "Nov";
monthHash["DEV"] = "Dec";
So that I can do this:
alert(monthHash[the_variable]);
Instead of using a switch to get through this.
When I try, I get an error message. Is there a way that a variable can contain a string identifier for a key in JavaScript?
source
share