Hi all,
Has anyone ever seen the following Javascript problem (in IE). I'm
trying to set up a hash of rating values to integers (which I'll then
use to sort an array of ratings). It looks like this:
var ratingsTable = new Object();
ratingsTable["AAA"] = 0;
ratingsTable["AA+"] = 1;
ratingsTable["AA"] = 2;
ratingsTable["AA-"] = 3;
ratingsTable["A+"] = 4;
ratingsTable["A"] = 5;
ratingsTable["A-"] = 6;
....
However, any values that contain the "+" or "-" don't get added. I up
with a hash containing
AAA = 0, AA = 2, A = 5
This is something I've never come across in javascript before, but then
again I've never had to do it. A colleague has suggested preprocessing
the strings coming in for comparison so that "AA+" becomes "AAPlus"
That'll certainly work but is somewhat of a kluge. Is there some way
to escape the + or - sign so that these work as keys that are strings?
Am I going about this in the completely wrong way? Thanks, any help is
greatly appreciated!
Regards,
Jason