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

187
Views
Why is filter & includes returning an empty array in the case below?

Why does the code snippet below return an empty array despite 'Delhi' being included in both arrays?

const cities = [
  { _id: '5bqAPcRutbZDgfdRT', name: 'Ahmedabad' },
  { _id: 'PSzMrGENYKfF2wbKQ', name: 'Anand' },
  { _id: 'tJZnaQuiy8bvvmv3B', name: 'Bangalore' },
  { _id: 'SFuvn99mtn5qgZrXh', name: 'Delhi' },
  { _id: 'SKFibyqad3sfqs3N2', name: 'Goa' },
  { _id: 'wLP4whAeYnaqDeZt7', name: 'Kolkata' },
  { _id: 'Hv8L7cw8Mn6m8uMXv', name: 'Lonavala' },
  { _id: 'vbc4RJjPq5xMGizbS', name: 'Mumbai' },
  { _id: 'uHaqkBZQqTEEhW4yv', name: 'Pune' },
  { _id: 'jfBaJf3ssqaX8zzx4', name: 'Surat' },
  { _id: 'pdcnk5jLPigh24iBe', name: 'Udvada' },
  { _id: '5EEZCdgN8zbBs5gKP', name: 'Vadodara' }
]

const addressSplits = [ ' India', ' Haryana', ' Delhi', 'DLF Place' ]

const city = cities.filter((el) => addressSplits.includes(el.name));

console.log(city);

Output: Array[] instaed of Array[{ _id: 'SFuvn99mtn5qgZrXh', name: 'Delhi' }]

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

0

Leading space in the addressSplit array. My bad guys. Thanks @CherryDT

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!