Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

102
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda