Hello All,
In the sample code for the Functional Programming: Sort an Array Alphabetically using the sort Method exercise, I believe the comparison function for the reverse alphabetical is incorrect and it doesn’t actually sort the array:
function reverseAlpha(arr) {
return arr.sort(function(a, b) {
return a < b;
});
}
It should be something like this…
function reverseAlpha(arr) {
return arr.sort(function(a, b) {
return a > b ? -1 : 1;
});
}
If I’m not off base, could someone please update it?
Thanks!