0
0
Javascriptprogramming~5 mins

String concatenation in output in Javascript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A*
B-
C+
D/
What will this output?<br>
console.log('JS' + ' Rocks');
AError
BJS Rocks
CJS+Rocks
DJSRocks
How do you embed a variable inside a string using template literals?
AUsing ${variable} inside backticks
BUsing + operator
CUsing quotes and +
DUsing single quotes only
What is the output of:<br>
let name = 'Anna'; console.log('Hello ' + name);
AHello Anna
BHello + name
CHello
Dname
Which is a benefit of template literals over + concatenation?
AThey are slower
BThey do not work with variables
CThey require more code
DThey allow multi-line strings easily
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.