We can easily append variables to a string using the plus equals (+=) operator.
let adjective = "really fun!!";
let str = "Learning basic JavaScript is ";
console.log(str += adjective);
The console will show the output:
Learning basic JavaScript is really fun!!
Top comments (3)
Actually it's not appending, because strings in JavaScript are immutable. You're creating new string and assign it the to the same variable.
If you search the google writing "append string in JavaScript" it will show you the concat method of joining two strings together. And append also means the same, concatenation.
Here I have created two variables that holds two different strings and inside the console.log() I've concatenate those two. So that's why I said appending variables.
such a grateful things to learn as beginner in javaScript !!!thank you mam for simplified code !!