Is it possible to sort arrays in ascending/descending order using the for loop JavaScript?
I\'ve been learning JS going through a few practice quest
If you want to get the max/min number in an array, why not use Math.max/Math.min?
Math.max/Math.min
If you want to sort the array, you can use sort method:
sort
var sorted = [3, 1, 6, 2].sort(); // sort ascending var sorted = [3, 1, 6, 2].sort(function(a, b){ return b - a; }); // sort descending