I am trying to generate an object via a for loop, the problem I am having is that the property name is not being generated instead it is just inserted as the variable name.
Here is an example:
for (let key in person) {
let obj = {key : person[key] };
console.log(obj);
}
If you run this it prints
{ key : "smith" }
The desired object would be
{ name : "smith" }
any ideas on how to achieve this? thank you in advanced.