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

239
Views
React Native: Else en un bucle for no funciona, el bucle omite la primera condición y usa de manera predeterminada el else en el bucle

En el código a continuación, tengo un bucle for que pasa por una matriz json y luego envía datos a una nueva matriz para usar. El problema es que el ciclo parece estar usando el else y omitiendo por completo la primera condición sin importar qué. Este es un comportamiento extraño, y no sé dónde está el error/error.

 const findCompaniesByCategory = async (category) => { setCat(category) var zip = await AsyncStorage.getItem('locationZip') var newCompanies = [] for(var i in companies){ if(companies[i].category == category && companies[i].zip == zip){ await newCompanies.push(companies[i]) await setSuggestions(false) await setUsers(newCompanies) await setHide(false) setNoResults(false) await setCompaniesView(true) }else if(companies[i].category != category){ await setHide(false) setCompaniesView(false) setNoResults(true) } } }
about 4 years ago · Santiago Gelvez
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!