Tell us what’s happening:
The example function reverseAlpha function doesn’t work on Chrome (works on FireFox).
function reverseAlpha(arr) {
return arr.sort(function(a, b) {
return a < b;
});
}
The slightly modified version works on both Chrome and Firefox:
function reverseAlpha(arr) {
return arr.sort(function(a, b) {
return a < b ? 1 : -1;
});
}
Is this a JavaScript version issue?
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/sort-an-array-alphabetically-using-the-sort-method/