Recall & Review
beginner
What is string concatenation in JavaScript?
String concatenation means joining two or more strings together to make one longer string.
Click to reveal answer
beginner
Which operator is commonly used for string concatenation in JavaScript?
The plus sign (+) operator is used to join strings together.
Click to reveal answer
beginner
What will this code output?<br>
console.log('Hello' + ' ' + 'World');It will output: Hello World<br>This joins the three strings with spaces in between.
Click to reveal answer
intermediate
How can template literals help with string concatenation?
Template literals use backticks (`) and allow embedding variables directly with ${variable}, making concatenation easier and clearer.
Click to reveal answer
intermediate
What is the difference between using + and template literals for concatenation?
Using + joins strings manually and can get messy with many parts.<br>Template literals let you write the whole string naturally and insert variables easily.Click to reveal answer
Which operator joins strings in JavaScript?
✗ Incorrect
The plus (+) operator is used to concatenate strings.
What will this output?<br>
console.log('JS' + ' Rocks');✗ Incorrect
The strings 'JS' and ' Rocks' are joined with +, resulting in 'JS Rocks'.
How do you embed a variable inside a string using template literals?
✗ Incorrect
Template literals use backticks and ${variable} to insert values.
What is the output of:<br>
let name = 'Anna'; console.log('Hello ' + name);✗ Incorrect
The variable name is concatenated with 'Hello ' to form 'Hello Anna'.
Which is a benefit of template literals over + concatenation?
✗ Incorrect
Template literals allow multi-line strings and easier variable insertion.
Explain how to join two strings in JavaScript and show an example.
Think about using + between two words.
You got /3 concepts.
Describe the advantages of using template literals for string concatenation.
Remember the ${} syntax inside backticks.
You got /4 concepts.