Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
Why is find function not recognized?
let students = ({id: 1, name: 'Alice'}, {id:2, name: 'Bob'}, {id: 3, name: 'Charlie' });
app.get('/',(req, res) => {
    //res.send('Home Page');
    //console.log(__dirname);
    //console.log(req.url);
    //console.log(req.query);
    res.sendFile('./views/index.html', {root: __dirname});
});


//send students with a particular ID back to the client
app.get('/students/:sid', (req, res) => {

    console.log(req.params);

    let id = req.params.sid;

    let student = students.find(element => element.id === parseInt(id));

    console.log(student);

    res.json(student);

});

in the console it says that the find function is not a function and is throwing me an error and I do not understand why.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

An array is initialized with square brackets, the first line should look like this:

let students = [{id: 1, name: 'Alice'}, ...];
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!