Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda