Bug? freeCodeCamp site is off?

In this problem, I couldn’t work out how to solve them until I come to the solution section. I then copied and pasted the solution provided but the output doesn’t change.

Site
/javascript-algorithms-and-data-structures/functional-programming/sort-an-array-alphabetically-using-the-sort-method/

function alphabeticalOrder(arr) {
  return arr.sort(function(a,b) {
    return a > b;
  });
}

That solution is incorrect for Chrome. You need a proper compareFunction.

Read through the documentation and you will see several examples and one of them is the solution for this challenge.

1 Like

Thank you for answering so quickly. Can you explain how different environment are different for something seemingly so basic?

If the proper compareFunction is used, it will work across all browsers.