let mutateVariables = {};
let zoneNames = ['atr2', 'paint2'];
zoneNames.forEach(zone =>
{ mutateVariables[`zone${zone}`] = d => d[`${zone}fga`] / d[`${zone}fgm`] }
);
The output seems incorrect, at least in the chrome devtools console, as I was expecting the function to show as zoneatr2: d => d.atr2fga / d.atr2fgm
. It looks like the zone was correctly appended into the function names, but not into the variables in the function. How can we tweak the code above such that the functions are created & displaying correctly in our object? Or perhaps everything is created just fine and this is just how the chrome devtools console is deciding to show the function?