Need help in variables

var myPet = ‘armadillo’;
console.log('I own a pet ’ + myPet + ‘.’);
prints same result as code

var myPet = ‘armadillo’;
console.log(‘I own a pet ’ + myPet);
then what +’.’ is actually do in first code ?

because the + '.' will add a full stop at the end, for example you own a cat:

i own a pet cat.


i own a pet cat

see? No full stop at the end of the sentence


Taken from MDN an example of string interpolation or concatenation, with embedded expressions

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.