Why use concatenation for sentences?

Why would you use + to concatenate two sentences rather than just make both sentences one string?

"This is the beginning. " + “This is the end.”; VS. “This is the beginning. This is the end.”

Your code so far


const myStr = ""; // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15

Challenge: Concatenating Strings with Plus Operator

Link to the challenge:

This is just a dumb example. Most times, you’re going to concatenate strings only when you need to insert the value of a variable into it. For example:

let age = 2022 - 1999;
let output = "I am " +  age + " years old. ";

Hope it helps.

Makes sense that way thanks.

1 Like