String Concatenation, online
Six activities your students do on their own devices. See who's finished, and their scores.
Learning
Understanding
Testing
String Concatenation in one minute
What students need to know
This code appends "!" to the end of greeting. This concatenates the text "Age: " with the age variable.
+ joins strings into a single combined string. Concatenation always uses +, never -.
Mistakes students make
- Concatenation uses +, not -, to join strings.
- Missing + between the two strings being joined.
- Extra + causes invalid syntax - only one + is needed.
- Concatenation uses +, not *, to join strings.
PREVIOUS · MODULE 6More Arithmetic: % and **
YOU ARE HERE · MODULE 7String Concatenation
NEXT · MODULE 8Template Literals
What students will learn in this module
Every question in Module 7
Quick questions
- Does + join two strings together in JavaScript?AYesBNo
- Is - used to join two strings together?AYesBNo
- Does leaving out + between two strings cause an error?AYesBNo
- Can you concatenate a string literal with a variable?ANoBYes
- Is a + + b valid syntax for joining two strings?ANoBYes
Key terms
Students type the meaning of:
+
Match the pairs
"Hi " + nameMatch it to what it doesfirst + " " + lastMatch it to what it doesCombines two strings into one using +Match it to what it doesJoins a string literal with a variable's valueMatch it to what it doeslet msg = "Hi " - name;Match it to what it doeslet z = x + + y;Match it to what it doesFill in the blanks
let msg = "Hi " _ name;
Hint: Type the operator that joins two strings together.
let full = firstName _ lastName;
Hint: Type the operator that joins two strings together.
let years = "Age: " _ age;
Hint: Type the operator that joins two strings together.
let combo = a _ b + c;
Hint: Type the operator that joins two strings together.
let msg2 = greeting _ "!";
Hint: Type the operator that joins two strings together.
Spot the error
Question 1
Alet msg = "Hi " - name;Bconsole.log(msg);Clet x = 1;
Question 2
Alet a = "Hello";Blet b = a "World";Cconsole.log(b);
Question 3
Alet x = "A";Blet y = "B";Clet z = x + + y;
Question 4
Alet first = "Sam";Blet last = "Lee";Clet full = first + last;Dlet full2 = first * last;
Question 5
Alet name = "Amy";Blet msg = "Hi " + name;Cconsole.log(msg);Dlet x = 1;Elet bad = Hi + name;
