Sort an Array Alphabetically using the sort Method 1

Sort an Array Alphabetically using the sort Method 1
0

I am working on Functional Programming: Sort an Array Alphabetically using the sort Method and I have the syntax and everything right, but I can’t pass the challenge. Then, I used the FCC code, still couldn’t pass.

Your code so far


function alphabeticalOrder(arr) {
  // Add your code below this line
   return arr.sort(function(a, b) {
    return a > b;
  });
  
  // Add your code above this line
}
alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/sort-an-array-alphabetically-using-the-sort-method

Syntax isn’t correct for some browsers, the hint in this case will not work for Chrome because it’s sort algorithm doesn’t work the same way. The callback should return -1, 0, or 1, yours returns true or false.

If you search the forums this has come up a number of times: there is a fix for the hint in place, but it isn’t love on the FCC site as of yet.