HTML and JavaScript Code
HTML Code ([Link])
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Variables</title>
<!-- Link to external JavaScript file -->
<script src="[Link]" defer></script>
</head>
<body>
<h1>JavaScript Variables Example</h1>
<div id="output"></div> <!-- This is where the output will be displayed -->
</body>
</html>
JavaScript Code ([Link])
// 1. A string with your name
const name = "ChatGPT";
// 2. A number representing your age
const age = 3; // (since ChatGPT launched in 2020)
// 3. A boolean indicating whether you like JavaScript
const likesJavaScript = true;
// 4. An object representing a car with properties: make, model, and year
const car = {
make: "Toyota",
model: "Corolla",
year: 2022
};
// Displaying the values on the page
const outputDiv = [Link]('output');
[Link] = `
<p>Name: ${name}</p>
<p>Age: ${age}</p>
<p>Likes JavaScript: ${likesJavaScript}</p>
<p>Car Details: ${[Link]} ${[Link]}, ${[Link]}</p>
`;