Course Content
Ninja Game
Ninja Game
For Loops Practice
In this chapter, you'll have the opportunity to apply your knowledge of for loops by tackling a practical task in the Ninja Game. This exercise will help reinforce your understanding of loops and how they can be used to efficiently perform repetitive tasks.
Swipe to show code editor
Goal: Move a column of sushi.
To achieve this, you will need to use for loops to iterate over the grid and move the sushi. You are provided with a function goDownN(ninja, n)
that moves the ninja down by n
cells. You can use this function to help complete the task.
Solution
Starter Map
Goal Map
Thanks for your feedback!
ninja.js
index.html
preset.js
For Loops Practice
In this chapter, you'll have the opportunity to apply your knowledge of for loops by tackling a practical task in the Ninja Game. This exercise will help reinforce your understanding of loops and how they can be used to efficiently perform repetitive tasks.
Swipe to show code editor
Goal: Move a column of sushi.
To achieve this, you will need to use for loops to iterate over the grid and move the sushi. You are provided with a function goDownN(ninja, n)
that moves the ninja down by n
cells. You can use this function to help complete the task.
Solution
Starter Map
Goal Map
Thanks for your feedback!