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
Check if value is included in any nested array

I am trying to find if an array of arrays includes a value. Is it possible to do this without a for loop?

The below always returns false.

const testArr = [
   [0,0,0],
   [0,1,0],
   [0,3,0]
]

console.log(testArr.includes(3))
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

testArr.join().includes(String(3))
about 4 years ago · Juan Pablo Isaza Report

0

testArr.reduce((a,b)=>{return [...a,...b]}).includes(3)
about 4 years ago · Juan Pablo Isaza Report

0

You have to handle each level of arrays separately, whether that is by looping or by using array functions.

testArr.some(subArr => subArr.includes(3));

This will return true if one or more of the sub arrays include 3.

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!