I am trying to create a hash out of linear array in javascript. The array looks like this from which I want to create key/value hash
[13,0.011872336272725,13,0.01872336272725,13,0.0001,13,0.000660168379,13,0.006225,13,0.0000001,13,0.00925411794166,13,0.00000001,13,0.00093192461111,12,0.00007242822,12,0.9,13,0.000000005011872336272715,11,0.000001]
so I want to create a hash that will contain values like this
days= { 13: 0.011872336272725, 13: .01872336272725, 12: 0.00007242822, 11: 0.000001 } etc
to do so I trying like this
for (var key in temphash) { var obj = temphash[key]; for(var t = xValues.length; t >= 0; t--) { if(obj[0] == xValues[t]) { var keyy = xValues[t]; if (!(keyy in days)) { days[keyy] = new Array(); } days[keyy].push(obj[1]); } } }
This xValues contains some values that I need to check if exist in temphash then only add it as key in days which will have final hash with all key and values in it.
I am pretty new in JavaScript so manage if it is silly question..;)