Find method in javascript

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

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.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.