-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathobjects exploration.html
More file actions
45 lines (34 loc) · 962 Bytes
/
objects exploration.html
File metadata and controls
45 lines (34 loc) · 962 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
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html>
<head>
<title>Javascript - Objects</title>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function(){
var me = {
"first":"erin",
"last":"sparling",
"employer":["Cooper Union", "Gannett", "Park Slope Food Coop"],
"placeOfResidence":"brooklyn",
"currentLocation":"Cooper Union"
};
console.log(me);
var introduction = "My name is " + me.first + " " + me.last + ".";
console.log(introduction);
var sentence = "";
for (var i = 0; i<me.employer.length; i++) {
if(i === me.employer.length - 1) {
//this only happens during the last item in the list
sentence = sentence + " " + me.employer[i] + ".";
} else {
//this happens for every item in the list
sentence = sentence + "I work at " + me.employer[i] + ", and ";
}
}
$("body").append(sentence)
});
</script>
</head>
<body>
</body>
</html>