SyntaxFix
Write A Post
Hire A Developer
Questions
You can't define an object literal with a dynamic key. Do this :
var o = {}; o[key] = value; return o;
There's no shortcut (edit: there's one now, with ES6, see the other answer).