0

Hi all, what should i do to repeat these 4 functions ?

https://code.sololearn.com/WPdZQJJdAy4y/?ref=app

13th Feb 2020, 6:54 PM
ehsan shahbazi
ehsan shahbazi - avatar
2 Answers
0
Hello, I think there are many solutions,for example: Using a for loop or a while loop.You can check that in the js courses. With a for loop: After line 2(so on line 3) you insert: for (var i=0;i<4;i++){ ***Your whole code*** } I choose i<4,but the numbers depend of how many times you would like to repeat it. Maybe also create a function(still starting line 3) that includes the for loop with your whole code and then call that function: function turningsquare(){ for(var i=0;i<4;i++){ ***Your code*** } } turningsquare(); And if you only want to call that function once in a while you don't need the for loop,only call your function. I think that will work, but anyway refers to the for or while loop courses...hope it will help. Have a good evening.
13th Feb 2020, 7:35 PM
EmmanueLZ.
EmmanueLZ. - avatar
0
Here is an example based on your code. https://code.sololearn.com/WvPeN2dHjKws/?ref=app You don’t need left, right, bottom, top. You can move the box just using left and top.
13th Feb 2020, 7:47 PM
Gabriel Ilie
Gabriel Ilie - avatar