I’m on the Javascript Practice exercise - Functions & Arrays, but I don’t see any help thread on that page.
I’m working on the question:
In this exercise, you will manipulate a list of the entire English alphabet.
alphabet = ["O", "U", "P", "H", "Q", "T", "Z", "Y", "E", "S", "F", "C" , "R", "V", "J", "L", "X", "A", "M", "G", "D", "I", "B", "W", " K "," N "]
- Use the built-in methods in arrays to sort the list.
- You should then print the first character in the list, but it should be a lowercase letter. ( Hint: toLowerCase() )
I figured out the correct answer as stated by the Solution sheet:
alphabet.sort();
However, the result I get is this:
(26) [" K ", " N ", “A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”, “I”, “J”, “L”, “M”, “O”, “P”, “Q”, “R”, “S”, “T”, “U”, “V”, “W”, “X”, “Y”, “Z”]
I’m not clear on why K and N are out of order while the rest of the array is correctly sorted?