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

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

6/10

Text Concatenation | Start Coder