Click to See Complete Forum and Search --> : string array


graemo
12-09-2002, 05:34 PM
Could some one tell me how to initialise a string array so that the code is the opposite to this one

var ones_numerals = new Array();
ones_numerals[0] = "";
ones_numerals[1] = "I";
ones_numerals[2] = "II";
ones_numerals[3] = "III";


i need the array so that when the I, II or III are used it will give the equivalent number which is the opposite to what the code above does!!

cheers

appreciated!!

Rick Bull
12-10-2002, 03:30 AM
Do you mean like this:


var ones_numerals = new Array();
ones_numerals["I"] = 1;
ones_numerals["II"] = 2;
ones_numerals["III"] = 3;
alert(ones_numerals["II"]);