Functional Programming: Sort an Array Alphabetically using the sort Method - something weird is happening

My own code kept failing. I thought this should have been an easy one. So I started googling sort() to make sure I wasn’t missing anything. To no avail.

I also tried:

function alphabeticalOrder(arr) {
  // Add your code below this line
  return arr.sort();
  // Add your code above this line
alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);

which technically should have worked. But it also failed.

So then I got so fed up, I looked at the solution code. And it turned out to be exactly what I had coded the first time around. To make absolutely sure, I copied and pasted the solution into my FCC console. And it still failed.

Then just when I was about to give up all hope, I tried the arr.sort() code again. And it worked…??

So I thought maybe there was a temporary technical-brain-freeze-glitch and re-tried the solution code. But that is still failing.

Not sure if this is a coding issue or a technical issue. Posting just in case others are seeing the same thing and getting frustrated.


Correct. Your code should work.

Try using chrome if you aren’t.

1 Like

Thanks @shimphillip. Unforunately, I was/am using Chrome. Dunno, maybe I was so tired I didn’t see some obvious mistake. That’s what I’m going to chalk it up to.