A parameter is an input name in a function definition. Calling addBonus(4) gives points the value 4. The function returns that input plus 2.
Change the two calls so addBonus displays 5 and then 9. Keep the provided calculation: each input receives 2 extra points.
5 9
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.