var country = "USA";
document.writeln("My name is John.<br>");
document.writeln("I live in the" + country + ".<br>");
// end hiding code -->
In the example above a variable named country
is declared that holds the string USA.
statement tells the browser to print on the screen what is contained inside the parentheses.
You should recognize the HTML tag <br>.
HTML tags are permitted inside writeln statements,
and perform just as they would in any HTML document. So, in this example, each writeln
statement is output to a different line. One thing to remember when adding HTML tags is
that they should be placed inside quotes like a string. It doesn't matter if you use single
or double quotes, the browser will treat them in the same fashion.
The second writeln statement will output
the variable country. The variable should not have
quotes around it. If you use quotes, the word country will be printed and not the value of the
variable, which is USA.