I have array
Game: [
{ game: 'SS', status: 2 },
{ game: 'CD', status: 2 },
{ game: 'AS', status: 2 },
{ game: 'SM', status: 2 },
{ game: 'GTA', status: 1 },
]
how can I find the GTA's status is equal to 1 using find method in js?
I have array
Game: [
{ game: 'SS', status: 2 },
{ game: 'CD', status: 2 },
{ game: 'AS', status: 2 },
{ game: 'SM', status: 2 },
{ game: 'GTA', status: 1 },
]
how can I find the GTA's status is equal to 1 using find method in js?
You can use filter
method:
const games = Game.filter(gta => gta.status == 1 );