Niantic interview question

Counting squares, debug this piece of code.