Transfer practice · Define addOne(value) to return value + 1. Display the results for inputs 0 and 5: 1 and 6.
v3 · Activity 1 of 1 · parameters · 3 min Runs here
Use a familiar idea in a different task. Read the changed requirement before running.
Define addOne(value) to return value + 1. Display the results for inputs 0 and 5: 1 and 6.
1 6
Lines must stay in order. Spelling, capitalization and spaces inside a message matter.
local function addBonus(points)
return points + 2
end
print(addBonus(8))The argument 8 becomes points. The return gives 10 back to print.
New syntax: (points), addBonus(4)
Different calls can give the same parameter different values. The name points is local to each call. Returning sends the calculated value back to the caller; print then displays it.
Select a word or symbol in this authored example. Your editor draft stays unchanged.
addBonuspoints
points 2
addBonus1
addBonus2This 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.