Question:

Define a goodSortArgs() function that takes a variable number of integer arguments an returns a sorted array. goodSortArgs(1, 44, 3) should return [1, 3, 44].

Answer:

function goodSortArgs () {
  var args = Array.prototype.slice.call(arguments, 0);
  var result = args.sort(function (x, y) {
    return x - y;
  });
  return result;
}

Keywords:

© 2017 QuizBucket.org