The purpose of loops | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

The purpose of loops

I know loops is to loops our code but what is it for ?

2nd Dec 2016, 2:28 PM
Leon lit
Leon lit - avatar
3 Answers
+ 3
In a real-world game application development context, loops are actually useful. For example if you were to make a game that spawn monsters, and you want to spawn 5 of them, instead of making 5 line of codes over again, you can simply just make a loop that loops itself 5 times. The good thing about it is that, you can reuse the loop and you can modify it too! Meaning that if you suddenly want to spawn 10 of them, you can just change certain values.
2nd Dec 2016, 2:31 PM
Wen Qin
Wen Qin - avatar
0
love u k2 shape
2nd Dec 2016, 2:47 PM
GeneralHamster
GeneralHamster - avatar
0
oh I never thought about that thanks :D
2nd Dec 2016, 3:36 PM
Leon lit
Leon lit - avatar