-2

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?

2
  • const foundGame = Game.find(({ status }) => status === 1) ? Commented Nov 2, 2020 at 12:42
  • MDN's documentation of find has several examples. What part of those are you not understanding? Commented Nov 2, 2020 at 12:43

2 Answers 2

0
Game.find(game => game.status===1)
Sign up to request clarification or add additional context in comments.

Comments

0

You can use filter method:

const games = Game.filter(gta => gta.status == 1 );

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.