I have a $.post jQuery call that calls a php file. The file then returns a JSON encoded array. Then, the array is mapped to edit some of the data in the array. However, I get the error arr.map is not function.
Here is the array being passed in the $.post call.
[{"set":"Alpha","key":"256"},
{"set":"Omega","key":"671"},
{"set":"Theta","key":"762"},
{"set":"Beta","key":"462"}]
Here is the map function.
idHash = {'Alpha': '1', 'Beta': '2', 'Theta': '3', 'Omega': '4'};
var arr = arr.map(function(item){
item.set = idHash[item.set]
return item;
})
After the map function, the array should look like this.
[{"set":"1","key":"256"},
{"set":"4","key":"671"},
{"set":"3","key":"762"},
{"set":"2","key":"462"}]