Tell us what’s happening:
Below is the official solution, and it is quite easy to figure out from the example. In addition, this works in my ide fine- yet does not pass. After searching the forums further down is the solution that works.
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"]);
Code that works:
function alphabeticalOrder(arr) {
// Add your code below this line
var newArr = arr.sort();
console.log(newArr);
// Add your code above this line
return newArr;
}
alphabeticalOrder
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 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