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

98
Views
Array excersize in Javascript

I have a function that receives as an argument an array of numbers called 'numbers' and must return an array containing the smallest number in the 'numbers' array at position zero and the largest number in the array 'numbers' in position 1.

  maxValue = Math.max(numbers)
  minValue = Math.min(numbers)
  varResult = ([minValue, maxValue]);

  for (let i = 0; i < numbers.length; i++) {
  console.log (varResult);
  } 
} ```
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can not pass an array to Math.min or Math.max.
You'll need to spread the numbers, like:

maxValue = Math.max(...numbers)
minValue = Math.min(...numbers)
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!