Sort Method, Result not being accepted

Tell us what’s happening:
I think it’s not accepting this as the right answer because the result gives back the elements in single quotes, but fcc wants it in double quotes.
Any ideas on what to do?

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"]); //['a', 'a', 'c', 'd', 'g', 'z']; but it wants all the elements in double quotes

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Double and single quotes are synonymous in JS - that is not the issue.

For the sort method, you have to consider a few possibilites - if it’s bigger, if it’s smaller, and if it’s the same. You need to return something different in each case (although I guess the last can be ignored and return undefined in some cases).

Please consult the docs on how sort works (always a good habit). Also keep in mind that the hint for this challenge is wrong and is being updated.

Take a look at the docs and see if you can figure it out. If not, check back and let us know and we’ll see if we can get you a little closer.

Thanks for the reply Kevin.
I just realized the problem in the result was that I kept getting an extra space before the first element of the resultant function. Still trying to solve it.

This is the issue

There is nothing in your code that would add an extra element in the array, don’t worry about that