Tell us what’s happening:
Could someone explain to me why this passed the challenge.
I referenced the examples given and I’m curious as to why the way they wrote it out didnt work for me and this way did.
Your code so far
function alphabeticalOrder(arr) {
// Add your code below this line
return arr.sort();
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/67.0.3396.87 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