Task: using the coding area on the top left move the outlined square to the red square and replace the color to black.
Functions and loops are very useful tools when coding. You may combine them any way you like. Put loops inside a function and call functions inside a loop.
You can combine multiple steps (statements) by grouping them inside a named function.
function northEast() { move.up(); move.right(); }
,then, when you want to run the combined steps, simply call the function: northEast()
For repetative tasks, loops are great. Use the for loop to set how many times you wish to loop. Then add the statement(s) within the {codeblock} that you want to repeat.
The syntax for the loop setting is very compact (loop=0; loop < 10; loop++)
, but all you need to remember for now is that you can change the number 10 to your own desired loop count.
for (loop = 0; loop < 10; loop++) { //this would move down 10 times: move.down(); }