Skip to content

4.2.1 Ghost Codehs Access

You start the loop at i = 0 . Now, i % 2 === 0 is true for the first iteration (0 is even), so you print "GHOST" first instead of "ghost".

If you are working through the (or AP Computer Science Principles) course on CodeHS, you have likely encountered an intriguing and often frustrating milestone: 4.2.1 Ghost . 4.2.1 Ghost Codehs

Here is the gold-standard solution that passes 99% of all "4.2.1 Ghost" tests: You start the loop at i = 0