Reputation: 5075
I have trying to get collection of data from json object using map and assign key, pair reference in loop but its not working out for me. I can read value in iterations but I need to assign to key and value where I need help. its not recognising "key" and "value"
var j1 = _preDefineAnswerOptions.map(function(item){
return ["key": item.preDefineAnswerId, "value": item.text];
});
Upvotes: 0
Views: 51
Reputation: 22534
You need to return an object. Use {}
around the key and value.
var j1 = _preDefineAnswerOptions.map(function(item){
return {"key": item.preDefineAnswerId, "value": item.text};
});
Upvotes: 1