//loping for objects
const users = [
{isPremium: false},
{isPremium: false},
{isPremium: false},
{isPremium: false},
{isPremium: false},
]
function setUsersToPremium(users) {
// users is an array of user objects.
// each user object has the property 'isPremium'
// set each user's isPremium property to true
// return the users array
for (let key in users) {
users['isPremium'] = true;
}
return users;
}
setUsersToPremium(users);
I am true to figure out how to loop through an array of objects and change their value from false to true. My result with this code is
[true, true, true, true, true ]
but what I want to do is change each
[isPremium: true]
I'm wondering what I'm doing that is keeping me from accessing this value.