
Write a variable in a text string using a dollar sign. - JavaScript Tutorial
Write a variable in a text string using a dollar sign.
-----------------------------------------------------------------------------------------------------
Write a variable in a text string using a dollar sign.
Hello, today we're going to show how to write variables in text strings with using a dollar sign.
We see, that we have two variables declared and initialized, thus variable firstName with the value John and variable lastName with the value Cage.
First we write the variable firstName into the text string by joining strings, where we must always add a plus sign between the variable and the text. The text must be placed in apostrophes.
We write the variable lastName into a text string using a dollar sign and curly braces, in which we place the variable lastName. In this case, we place the entire text string in the apostrophes.
Now let's try to display the page and see that joining text strings with plus signs and joining strings using the dollar sign works the same and both entries display the variable correctly.
Thank you for watching this video and if you like, subscribe to this channel and put like.
コメント