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

274
Views
JavaScript: compruebe si el valor ya está incluido en una matriz con subvalores

Tengo una matriz que tiene subvalores para cada valor de la matriz y estoy tratando de verificar si ya existe un subvalor dentro de la matriz. Normalmente solo usaría array.includes() pero eso no funciona en este caso. ¿Cómo verificaría los subvalores? Esto es lo que quiero decir:

La estructura de la matriz: ingrese la descripción de la imagen aquí

Lo que probé:

 if (dataArray.includes(`classCRN: ${classesArray[i]}`) === false) { // ...rest of code... }
about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

Puede usar el método array.some() para comprobar que hay los mismos subvalores.

 if(dataArray.some(item => item.classCRN == classesArray[i])){ ...... }
about 4 years ago · Santiago Gelvez Report

0

Simplemente recorra la matriz para encontrar la propiedad:

 let arr = [ {name: 'test', origin: 'something', value: 'bb123'}, {country: 'Serbia', city: 'Belgrade'}, {something: 'here', hey: 'there'} ] console.log(isInnArray(arr,'there')) //true console.log(isInnArray(arr,'mystring')) //false function isInnArray(arr, findMe) { for(let i = 0; i < arr.length; i++) { for (const [key, value] of Object.entries(arr[i])) { if(value===findMe) return true } } return false; }

about 4 years ago · Santiago Gelvez 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!