v3 · Activity 5 of 8 · assignment · state-updates · 2 min Runs here
Read the current value, add 5, and store the result back in coins. Assignment updates the stored value; = does not ask whether the two sides are equal.
Keep a local variable and update it with addition. Change the amount added so its final value is the number 18, then display the stored value.
18
Lines must stay in order. Spelling, capitalization and spaces inside a message matter.
local score=3
score=score+4
print(score)The update stores 7 before it is displayed.
New syntax: coins = coins + 5
On the second line, the right side is calculated first using the current value. The left side names the variable that receives the result.
The count starts at 10. Adding 5 stores 15. A later print reads the updated value, rather than the original 10.
Select a word or symbol in this authored example. Your editor draft stays unchanged.
10
5
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.