Learn Lua · First steps · Lesson 3 of 4

Text

Text in Lua is called a string: characters inside double quotes, like "Ada". .. (two dots) joins strings end to end, and # counts the characters in one:

LUA
"Print" .. "Shop"   --> "PrintShop"
#"Ada"              --> 3

Lua adds nothing between the strings it joins. To get a space, put one inside the quotes: "Hello, " .. "Ada" gives "Hello, Ada". Numbers join too, and become text:

LUA
"Order " .. 42  --> "Order 42"

\n inside quotes starts a new line, so "one\ntwo" is two lines of text.

Steps

  1. Set name to the full name: first, a space, then last.
  2. Return letters: how many characters the full name has, counting the space.
  3. Return lines: first and last on two separate lines.
Show a hint

Join three strings for the name: first, " " and last. # works on a name that holds a string, as well as on a string in quotes.