0

I have this json array

var currencyformats =
{"USD":[
    {'symbol':'$', 'left':true}
],
    "UAH":[
        {'symbol':'₴', 'left':true}
    ],
    "EUR":[
        {'symbol':'€', 'left':false}
    ]
};

How retreive '₴' ? I tried this (in cookie "to" I've "UAH")

currencyformats[$.cookie("to")].symbol

but I've obtained undefined

BILL
  • 4,711
  • 10
  • 57
  • 96

1 Answers1

1

The problem is that under each country code, you've defined an array with a single object. That means that after you access the country code, you'll need to also access the first index in the array.

So, assuming the cookie is set to the value that you're expecting:

currencyformats[$.cookie("to")][0].symbol;
Justin Niessner
  • 242,243
  • 40
  • 408
  • 536