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

128
Visualizações
How to sort the array and display it to the console using ForEach and Filter?

How to sort the array and display it to the console using ForEach and Filter, you first need to display all the last names, after that, the last names with the letter "F"? What am I doing wrong? 'use strict'; // https://reqres.in/api/users

fetch('https://reqres.in/api/users?per_page=12')
    .then((response) => {
       return  response.json();
    })
    .then((body) => {
        body?.data.forEach((item) => {
            console.log(item.last_name);
        })
        const filtered = body?.data.filter((item) => {
            return item.last_name === 'F';
            console.log(filtered);
        });
    console.log(filtered);
 });
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You are not checking the first letter of the last name

fetch('https://reqres.in/api/users?per_page=12')
  .then((response) => {
    return response.json();
  })
  .then((body) => {
    const filtered = body?.data.filter((item) => {
      return item.last_name[0] === 'F';
    });
    console.log(filtered);
  });

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