I'm working with an array of users and trying to filter out the admins by finding their indices in the array, but I'm running into some issues. Here's my code:
var users = [
{name: "Jeff", IsAdmin: false},
{name: "Jonah", IsAdmin: true},
{name: "Jonathan", IsAdmin: true}
];
var admins = users.findIndex(function (user) {
user.IsAdmin == true;
});
var regularUsers = users.filter(function (value, index) {
return admins.indexOf(index) == -1;
});
Unfortunately, this routine is not working as expected. The admins variable returns null and the filter function is malfunctioning.
Is there a simpler way to accomplish this task?