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

189
Views
Recuento de positivos/suma de negativos

Se supone que debemos devolver el recuento de todos los números positivos dados en una matriz y la suma de todos los números dados en la misma matriz. Alguien podría decirme que estoy haciendo mal por favor. Yo realmente lo apreciaría. Esto es lo que puse como mi código (JavaScript):

 function countPositivesSumNegatives(input) { let arr = []; let count = 0; let neg = 0; for (let i = 0; i <= input.length; i++) { if (input[i] > 0) { count++; } else if (input[i] < 0) { neg += input[i]; } return arr.push(count, neg); } }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

 function countPositivesSumNegatives(input) { let count = 0; let neg = 0; for (let i = 0; i <= input.length; i++) { if (input[i] > 0) { count++; } else if (input[i] < 0) { neg += input[i]; } } // Return outside the for loop return [count, neg]; } console.log(countPositivesSumNegatives([1,2,4,-1,0,-2,3,-4]))

about 4 years ago · Juan Pablo Isaza Report

0

function countPositivesSumNegatives(input) { let count = 0; let neg = 0; for (const number of input) { if (number > 0) { count++; } else if (number < 0) { neg += number; } } return [count, neg]; }
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!