Text Concatenation
So far, we have printed each piece of text on a new line. What if we want to combine the text and print it on one line? We can do this using the +
operator. For example:
let day = "Saturday";
console.log("Today is " + day + ".");
This will print:
Today is Saturday.
We often use concatenation when we want to insert the value of a variable (or multiple variables) into text.
Instructions
Print John Doe
using the console.log
command by combining the firstName
and surname
variables.
Hint: Insert " "
between firstName
and surname
.
Start programming for free
6/10