Sort an Array Alphabetically using the sort Method not checking

Tell us what’s happening:

I think there is a bug in the verifying system the code is correct but it is not verifying correctly.

Your code so far
function alphabeticalOrder(arr) {
// Add your code below this line
return console.log(arr.sort(function(a,b) {
return a > b;
}));

// Add your code above this line
}
alphabeticalOrder([“a”, “d”, “c”, “a”, “z”, “g”]);


function alphabeticalOrder(arr) {
  // Add your code below this line
   return console.log(arr.sort(function(a,b) {
    return a > b;
   }));
  
  // Add your code above this line
}
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.100 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

@Apoorvmahajan12 it is working well here on my end. Try refreshing your browser.

1 Like

one, if you return a console.log you are just returning undefined

two, don’t trust this way as it is browser dependant. the sort function expect a -1, 0 or +1 from the callback (or at least a negative or positive number) - check the documentation on sort()

1 Like

thanks
i will try to solve it by any other way

1 Like