โ ๐ Lua World
๐ Level Up!
You can practise without a player, but pick a player to score points!
๐ The mission
Today you unlock
If statements choose a path
An if statement checks a condition and chooses which answer to return. Order matters: check the special cases first.
๐ก Hint ladder
- Use if / elseif / else with end at the bottom.
- Check the biggest numbers first: if level >= 10 then ... elseif level >= 5 then ...
๐งช Coach checks
- โฏ level 1 is Noob
- โฏ level 4 is Noob
- โฏ level 5 is Pro
- โฏ level 9 is Pro
- โฏ level 10 is Legend
- โฏ level 99 is Legend
Live coach
Getting ready
โโโ
๐ฌ if / elseif / else picks ONE branch. Check the biggest numbers first!
function potionSize(ml)
if ml >= 100 then
return "BIG potion"
elseif ml >= 50 then
return "medium potion"
else
return "tiny potion"
end
end
print(potionSize(120)) -- BIG potion
print(potionSize(60)) -- medium potion
print(potionSize(10)) -- tiny potion
๐ It printed:
Nice โ you saw it work!
๐ Output
๐งฉ Gaps filled! Ready to write it all yourself?