+ 1

Could someone explane the example from battle?

don't understand 2 moments: 1. Why the "for" do only 1 iteration? 2. what do "break"? whithout "break" nothing happpened))) https://code.sololearn.com/cw2j3MRB8777/?ref=app

13th Apr 2018, 6:16 PM
andrey
andrey - avatar
3 Answers
+ 1
1. It is because of the fact that for loop in its first run returned some value & hence the code after return statement remained unexeceuted! 2. After the return statement, there is no sense of break keyword ;) In normal cases, inside a loop structure (like a for loop or a while loop), break keyword stops further execution of the code, and jumps out of the loop!
13th Apr 2018, 6:24 PM
777
777 - avatar
+ 1
and "return" so stop a loop as a "break"?
13th Apr 2018, 6:27 PM
andrey
andrey - avatar
+ 1
english is difficult for me))))
13th Apr 2018, 6:29 PM
andrey
andrey - avatar