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

142
Views
¿Puedo ver un gran número con Array.prototype.reduce?
const squareList = arr => { return arr .filter(number => number > 0 && number % parseInt(number) === 0) .map(number => Math.pow(number, 2)) // [25,9] .reduce((bigN, number) => bigN > number) }; const squaredIntegers = squareList([-3, 4.8, 5, 3, -3.2]); console.log(squaredIntegers); // true

Mi propósito es imprimir el número grande en la matriz en la consola después de reduce , pero no pude encontrar cómo ver los números en la cadena y cómo compararlos.

¿Puedo hacer esto con reduce ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

lo más probable es que desee que su función de reducción se vea así:

 reduce((bigN, number) => bigN > number ? bigN : number)

pero también puedes usar la función Math.max:

 const squareList = arr => { return Math.max(...arr .filter(number => number > 0 && number % parseInt(number) === 0) .map(number => Math.pow(number, 2))) };
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!