Your if statement that checks if the length is zero is at the end of your function. Returning false doesn't cancel code that has already run; you have to return before the LI gets added. Move that if statement to the top of the function, like so: