I have a data object like this :
{ '108': '4',
'1001': '4',
'1027': '1',
'1128': '2',
'1284': '1',
'1300': '4',
'1313': '4',
'1327': '2',
'1334': '1',
'1351': '4',
'1356': '1' }
Here for eg '108' is the key and '4' is the value.
I have declared an array called valuearray;
Now I want to put the data object into the extarray.
What i have done :
var x;
var count = 0;
for(x in data){
extarray[count] = data[x];
count++;
}
x refers to the keys in data object I have used the count variable to set index in extarray.
when i do console.log(extarray) it gives me the output as
[ '4',
'4',
'1',
'2',
'1',
'4',
'4',
'2']
but my expected output for console.log(extarray) is :
['108': '4',
'1001': '4',
'1027': '1',
'1128': '2',
'1284': '1',
'1300': '4']
where 108 is the key and 4 is the value in reference to the above expected array. if i do it like extarray[x] then it doesnt work as expected.
my basic requirement is that the key and value in the data object and the extarray should be same If I do extarray[1001] then the output should come as 4 (refer the data object) How do I do it?