Question:

Sort the values in the following array in ascending report: [32, 1, 44, 9]

Answer:

[32, 1, 44, 9].sort(function (x, y) {
  return x - y;
})

The sort() method takes an anonymous callback function as a parameter.


Keywords:

© 2017 QuizBucket.org