-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject4_dictionaries.html
More file actions
35 lines (28 loc) · 916 Bytes
/
Copy pathProject4_dictionaries.html
File metadata and controls
35 lines (28 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript Dictionary Assignment</title>
<script src="JS/main.js"></script>
</head>
<body>
<h1>Project 4: Dictionaries and Delete</h1>
<p id="Dictionary" onclick="my_Dictionary()">Click here to see if the value exists!</p>
</body>
</html>
//main.js
function my_Dictionary() {
// Creating a JavaScript Object (Dictionary) with Key-Value Pairs (KVPs)
var Car = {
Make: "Dodge",
Model: "Viper",
Color: "Red",
Engine: "V10",
Year: 2017
};
// The delete statement removes the "Engine" key from the Car object
delete Car.Engine;
// Attempting to output the "Engine" value to the HTML element
// Since it was deleted, the output will display as "undefined"
document.getElementById("Dictionary").innerHTML = Car.Engine;
}