Trouble passing the sort array challenge

I am having trouble in passing this challenge.
Can you please point out where am I doing wrong?

My 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
}
console.log(alphabeticalOrder(["a", "d", "c", "a", "z", "g"]));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 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

It’s weird that the challenge is asking you to run the return function for letters. It makes sense for numbers because they return as a string. Really all you need is this and it passes the challenge.
-J

  // Add your code below this line
    return arr.sort();
   // Add your code above this line
1 Like