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

117
Views
How to assign an IF statement inside a map function

I am trying to assign an IF statement inside a map function but it asks for a return. If I put the return, in front of the IF, does not work. Currently getting the following error on Lint: Line 78:52: Array.prototype.map() expects a return value from arrow function array-callback-return

I expect just to push objects into the array.

What is the correct way to assign the IF inside a map?

     { ingredientIndex.map((currentIndex) => {
        const ingredient = detail[`strIngredient${currentIndex}`];
        const measure = detail[`strMeasure${currentIndex}`];
        if (ingredient) {
          validIngredients.push(`${ingredient} - ${measure}`);
        }
      }) }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

ingredientIndex.forEach(currentIndex => {
                ^^^^^^^
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!