Transfer practice · With count = 0, display Empty. == checks whether values are equal. Check count == 0 before the general count <= 3 branch that displays Low.
v3 · Activity 1 of 1 · if-elseif-else · 9 min Runs here
Use a familiar idea in a different task. Read the changed requirement before running.
With count = 0, display Empty. == checks whether values are equal. Check count == 0 before the general count <= 3 branch that displays Low.
Empty
Lines must stay in order. Spelling, capitalization and spaces inside a message matter.
local level = 12
if level >= 10 then
print("Mentor")
elseif level >= 5 then
print("Workshop")
else
print("Training")
endOnly Mentor appears because the first matching branch handles this value.
New syntax: elseif
if checks the first condition. elseif checks another condition only when earlier ones were false. else handles the remaining cases. end closes the decision.
Order matters when several conditions could be true. Check the most specific case first. A high-level visitor also meets a lower requirement, so a general check placed first can hide a special message.
Each return finishes this function call. Different branches may return different messages, but each visitor receives one result.
Select a word or symbol in this authored example. Your editor draft stays unchanged.
level 10
level 5
level 10
This is a private experiment copy. It does not replace your answer or complete the activity.
Your output will appear here.
Replace this code with the starter? Download your draft to keep a copy.
Your output will appear here.
Sign in with RoCreators to save private progress across devices. Community verification is separate.