This is a code that I'm using to practice. The prompt line works. However, nothing gets printed into the browser when I run it on both chrome and firefox. I've also tried using <br>
instead of <br/>
with no luck.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Chapter 2, Example 5</title>
</head>
<body>
<script>
var greetingString = "Hello";
var MyName = prompt("Please enter your name");
var concatString;
document.write(greetingString + " " + myName + "<br/>");
concatString = greetingString + " " + myName;
document.write(concatString);
</script>
</body>
</html>
As others have mentioned about the book, it is using some dated terminology such as .bgColor
. However, I checked and neither document.write()
or <br>
is depreciated.
` or `
` recommended? Also, do most modern webpages include the `lang="en"` in the html section? – James Jun 22 '16 at 20:40
` question: [HTML 5: Is it
,
, or
?](http://stackoverflow.com/q/1946426/4642212). As for the `lang="en"` question: it’s better for semantics and SEO to have it. See [What is lang attribute of the tag used for?](http://stackoverflow.com/q/14649798/4642212). All your questions are already answered elsewhere. – Sebastian Simon Jun 22 '16 at 20:43