v3 · Activity 12 of 12 · numbers · strings · concatenation · 7 min Runs here
.. joins pieces of text. Calculate the numeric level first, then use tostring() to put that number into a readable label.
Mira starts at level 3 and earns 2 levels. Return the text Mira | Level 5. The example calculates the new level before joining the label. The checker assesses the returned text.
Interface: Return the composed player display string.
| Input | Expected |
|---|---|
Player information | "Mira | Level 5" |
local level = 3 + 2
return "Level " .. tostring(level)The addition calculates 5; joining text creates Level 5. return gives that complete text to the checker.
New syntax: .., tostring()
Numbers support arithmetic such as +, -, * and /. Text uses .. for concatenation. Joining "Level " and 4 creates text; it does not add a number to a sentence.
tostring converts a value into text intentionally. Some concatenations can coerce numbers, but making the conversion visible helps you distinguish calculation from presentation.
Calculate the result first, then turn it into a readable label. Quoted "12" is text; unquoted 12 is a number.
Select a word or symbol in this authored example. Your editor draft stays unchanged.
name
level 3
earned 2
nextLevel level earned
name nextLevelThis is a private experiment copy. It does not replace your answer or complete the activity.
These inputs apply when your scratchpad returns the function described by the activity interface.
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.