I have a script which has an array called metaData that includes product IDs and quantities. It looks like this:
"PRD 6060BNDISHRT-CHARCOAL-SMALL": 3, "PRD 6060BNDISHRT-CHARCOAL-MEDIUM": 3, "PRD 6060BNDISHRT-CHARCOAL-LARGE": 4, "PRD 6060BNDISHRT-CHARCOAL-XL": 3, "PRD 6060BNDISHRT-ALLOY-SMALL": 0, "PRD 6060BNDISHRT-ALLOY-MEDIUM": 2, "PRD 6060BNDISHRT-ALLOY-LARGE": 1, "PRD 6060BNDISHRT-ALLOY-XL": 3, "PRD 6060BNDISHRT-BLACK-SMALL": 1, "PRD 6060BNDISHRT-BLACK-MEDIUM": 0, "PRD 6060BNDISHRT-BLACK-LARGE": 0, "PRD 6060BNDISHRT-BLACK-XL": 4, "PRD 6060BNDISHRT-CABERNET-SMALL": 2, "PRD 6060BNDISHRT-CABERNET-MEDIUM": 2, "PRD 6060BNDISHRT-CABERNET-LARGE": 3, "PRD 6060BNDISHRT-CABERNET-XL": 2, "PRD 6060BNDISHRT-NAVY-SMALL": 3, "PRD 6060BNDISHRT-NAVY-MEDIUM": 3, "PRD 6060BNDISHRT-NAVY-LARGE": 0, "PRD 6060BNDISHRT-NAVY-XL": 3
This code:
var stockChicago = metaData;
alert(stockChicago);
results in the above list (or as much as will fit in the alert box).
Now, if I do this, I should get the result of the value for that key (it's the second one on the list), right?:
var stockChicago = metaData["PRD 6060BNDISHRT-CHARCOAL-MEDIUM"];
alert(stockChicago);
I expect the response to be "3," but instead, I just get "undefined." I've tried it without the quotes and have searched everywhere I can think of to figure out what I'm doing wrong. Like I said, I figure it's something very simple, but for the life of me I can't figure it out!