EXERCISE 1: Variables and Output - Solution Code

← Back to Assignment

Solution Files

index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Exercise 1 - Variables and Output</title>
</head>
<body>
    <h1>Exercise 1: Variables and Output</h1>

    <script src="script.js"></script>
</body>
</html>
script.js
// Declare variables
let firstName = "John";
let age = 25;
let isStudent = true;

// Output to webpage
document.write(`<p>Hello, my name is ${firstName}</p>`);
document.write(`<p>I am ${age} years old</p>`);
document.write(`<p>I am a student: ${isStudent}</p>`);