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

126
Views
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 answers
Answer question

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 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!