WHILE


while condition do
	--code to repeat
end
condition a variable or statement that will resolve to true or false. The code inside of this loop will repeat for as long as this condition is true.

"WHILE LOOPS" repeat the code after DO and stops repeating when the condition is false.

Example:

b = 4
while b < 10 do
	print( b )
	b += 1
end

--prints: 4 5 6 7 8 9

Images in this Guide by NerdyTeachers is licensed under CC BY-SA 4.0

842

18 Mar 2023

Font