Appendix – Practice Exercise, Project, and Self-Check Quiz Answers

Chapter 1, Getting Started with JavaScript

Practice exercises

Practice exercise 1.1

4 + 10
14
console.log("Laurence");
Laurence
undefined

Practice exercise 1.2

<!DOCTYPE html>
<html>
 
<head>
  <title>Tester</title>
</head>
 
<body>
  <script>
    console.log("hello world");
  </script>
</body>
 
</html>

Practice exercise 1.3

<!DOCTYPE html>
<html>
 
<head>
  <title>Tester</title>
</head>
 
<body>
  <script src="app.js"></script>
</body>
 
</html>

Practice exercise 1.4

let a = 10; // assign a value of 10 to variable a
console.log(a); // This will output 10 into the console
/*
This is a multi-line
Comment
*/

Projects

Creating an HTML file and a linked JavaScript file

<!doctype html>
<html>
  <

Get JavaScript from Beginner to Professional now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.