Consider this code
const b = {
users: [
{
"name": "bob",
"id": 0
},
{
"name": "sam",
"id": 1
},
{
"name": "tom",
"id": 2
},
]
}
const include = [1]
const c = b.users.filter(user => user.id in include)
console.log(c)
In my array include, I have the number 1 which references the id in the user object. c should return the "sam" one but instead returns "bob" who has id 0. I'm not understanding why ?
> console.log(c)
users: [
{
"name": "bob",
"id:" 0
}]