Hi,
I'm looping through a set of invoice figures trying to calculate totals for tax. I have this snippet of code in my loop to create an array/object on the fly and calc the total :-
- ivaRates[(ivaRate)] = (ivaRates[ivaRate]===undefined? 0: ivaRates[ivaRate] )+ ivaValue;
When type ivaRates in the console, I get what I expect:-
7.00% 35.179200000000044
16.00% 0.5760000000000001
I was hoping to use $.each() to extract the key,value pairs, but my statement:-
- $.each(ivaRates, function(key, value) {
- alert( key+ ': ' + value );
- });
does not work, it doesn't iterate through the array.
I don't really know what I have create with the first statement - an array, an object. Should this work and is there any other way I can retrieve the key.
Thanks