+ 1
How to find element in array and return
In this api array of objects, I need to find the post with ID #7 https://code.sololearn.com/W6vBMkE1Y0kk/?ref=app
7 Answers
+ 2
Here's the same code but tweaked a bit. It fetches the data using the Fetch API, then finds the object with an id of "7" using the "find" method and logs the id.
https://code.sololearn.com/WgqEfw2nLJ6S/?ref=app
+ 3
you can use the filter() method:
https://code.sololearn.com/W9S5o6jAYXYD/#js
+ 3
Rest api called be called by id number
https://jsonplaceholder.typicode.com/posts/7
+ 2
I found it. It was the find() method
+ 1
you do linear search with an for and an if-statment inside
+ 1
That's exactly what I got. Dope!