We have developed a learning game to teach loops, nested loops, and arrays using scaffolding and interactive visualization. We compare the game to a traditional programming assignment in an introductory computing laboratory. In our study, 17 Introduction to Computer Science labs were randomly assigned to play the learning game first and half to write a program first. Our results show that students playing the learning game first learn more, and that students prefer the game assignment to the traditional assignment. These results suggest that incorporation of gamebased assignments is beneficial to student learning.