I have a map
function and would like to pass in a variable as a Key
such that the obj.item
below takes the variable Salary
to become Salary
as the key
instead of item
.
weeklyData.map(function(obj) {
var day = obj.day;
var item = "Salary";
if (day === "Day") {
obj.item = "text"; // obj.item should be Salary as key
obj = obj;
};
return obj;
});