Find method in javascript

app.get(‘/api/persons/:id’, (req, res)=> {
const id = Number(req.params.id);
const getPerson = persons.find(person =>
{
person.id === id? person
: “no person found”
});
console.log(getPerson)
})

why m i getting undefined? what m i doing wrong?

You aren’t quit using the find method correctly.

MDN: Array.prototype.find()

Pay special attention to the type of value the callback function you pass into find should return.