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

204
Views
Find min and max value in an array in javascript

I have an below array with elements.

Array [
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  4116.38,
  4120.87,
  0,
  0,
  0,
]

How can i filter all the "0" value and the maximum value from the array?

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

0

You don't, you just use const maxInYourArray = Math.max(...yourArray), relying on modern spread syntax to turn your array into distinct arguments, because the Math.max function can take an arbitrary number of values as function arguments and returns the maximum value amongst them.

The same applies to Math.min, but that will obviously give you 0, so if you want to ignore all those zeroes, filter them out first: const minInYourArray = Math.min(...yourArray.filter(v => v!==0))

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!