Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Problems with plus or minus sign as key in a javascript hash?

Reply
Thread Tools

Problems with plus or minus sign as key in a javascript hash?

 
 
jmdolinger@earthlink.net
Guest
Posts: n/a
 
      11-24-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IE control plus/minus zoom problem dorayme HTML 6 06-27-2010 12:19 AM
json > minus, colon, plus character key problem Marc Javascript 2 04-30-2007 08:43 AM
Math.ceil/floor Vs parseInt Vs plus/minus RobG Javascript 6 07-09-2005 01:08 PM
Firefox plus and minus Trond Ruud Firefox 2 12-07-2004 05:31 PM
why plus can be minus. Another of Microsoft's trick? claude uq C++ 5 12-17-2003 04:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57