In JavaScript, we can assign strings to a variable and use concatenation to combine the variable to another string. To concatenate a string, you add a plus sign+ between the strings or string variables you want to connect. let myPet = 'seahorse'; console.
First, the list is defined and assigned to a variable. Then, using this variable we call the append() method, passing the element that we want to append (the string "B" ) as argument.
Like this:
var str = 'blah blah blah';
str += ' blah';
str += ' ' + 'and some more blah';
var str1 = 'abc';
var str2 = str1+' def'; // str2 is now 'abc def'
var str1 = "add";
str1 = str1 + " ";
Hope that helps,
Dan
Ronal, to answer your question in the comment in my answer above:
function wasClicked(str)
{
return str+' def';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With