โ ๐ Lua World
๐ Team Picker
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
- The % operator gives the remainder after dividing.
- number % 2 == 0 means even.
๐งช Coach checks
- โฏ 4 is Blue
- โฏ 7 is Red
- โฏ 0 is Blue
- โฏ 13 is Red
Live coach
Getting ready
โโโ
๐ฌ % gives the remainder. Remainder 0 when dividing by 2 = even number.
print(4 % 2) -- 0 (4 is even) print(7 % 2) -- 1 (7 is odd) function isEven(n) return n % 2 == 0 end print(isEven(10)) -- true
๐ It printed:
Nice โ you saw it work!
๐ Output
๐งฉ Gaps filled! Ready to write it all yourself?