Hello Code Academy Community,
I am trying to understand the difference between String interpolation and String concatenation.
Let’s take the following example:
If I want as an output to have the following sentence: "I own a pet armadillo. "
I can do either with a simple String concatenation :
const myPet = 'armadillo';
console.log('I own a pet' + ' ' + myPet);
// Output: I own a pet armadillo.
Or with a String Interpolation:
const myPet = 'armadillo';
console.log(`I own a pet ${myPet}.`);
// Output: I own a pet armadillo.
What is the difference? When should I use the String Interpolation or the String Concatenation?
Link of the course: https://www.codecademy.com/courses/introduction-to-javascript/lessons/variables/exercises/string-interpolation-ii
Thanks,
Benjamin.