Please consider the below object as example:
let roomsData = [{
"room_ID": "100",
"Seats_Available": 4,
"Amenities": ["AC", "Hot Water"],
"Price": "10000"
}, {
"room_ID": "203",
"Seats_Available": 6,
"Amenities": ["AC", "Hot Water", "Washing"],
"Price": "10000"
}, {
"room_ID": "301",
"Seats_Available": 4,
"Amenities": ["Non AC", "Hot Water"],
"Price": "10000"
}]
If we have have 100 as room ID (i.e the value) in above example with us then I want to get the output as the complete array element like below:
{
"room_ID": "100",
"Seats_Available": 4,
"Amenities": ["AC", "Hot Water"],
"Price": "10000"
}
Can you please explain if there is any solution for that?
find. (The linked question does the same withfilter, returning all matching elements, but since you are looking for only one element anyway,findis the better way.)