I am not quite sure why my solution isn’t working…I run my solution in vscode vs the test cases and I return what it says should be returned. Could someone point me to where I am going wrong, or if this challenge is broken… Thanks!!
Your code so far
function alphabeticalOrder(arr) {
return arr.sort( (a, b) => {return a > b;})
}
alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36.
The callback function should return -1, 0 or 1, yours does not do that. The hint was correct for all browser up until Chrome adjusted how sort worked in October last year (and still works fine in other browsers), there is a fix to edit the hint but it isn’t live yet. The fix for you is to return the correct thing from the function you give to sort, it currently isn’t correct.
And have a search on the forums - this has come up a lot because of the hint code not working in Chrome (and the fact that the solution worked fine up until recently, so if you google around you’ll find a lot of people using this method to sort), here’s one of my earlier answers: