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

119
Views
Trouble with sorting a numerical array in Javascript
var points = [40, 100, 1, 5, 25, 10];

points.sort(function(a, b){return b - a});

Above is my code. I am using the Khanacademy.com interface to make a program where the computer is give an array of numbers and it sorts them into ascending order. However, an error keeps coming up even though I copied this off a website and this method of sorting in JavaScript has been repeatedly stated across many websites.

The error that continues to appear states, "Did you forget to add a comma between two parameters?" Whenever I ask it to show me where, it always places my cursor here:

points.sort(function(a, b){return b - a});
                                 ^
                             
                             

Can someone please tell me what is wrong with my code? Or if you have a better way of sorting numbers, I am fine with that, too.

about 4 years ago · Juan Pablo Isaza
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!