-
Notifications
You must be signed in to change notification settings - Fork 0
/
js_objects.html
52 lines (44 loc) · 1.39 KB
/
js_objects.html
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
46
47
48
49
50
51
52
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Java Script Objects</title>
</head>
<body>
<script type="text/javascript">
const students = [
{ name: 'Remy', cohort: 'Jan' },
{ name: 'Genevieve', cohort: 'March' },
{ name: 'Chuck', cohort: 'Jan' },
{ name: 'Osmund', cohort: 'June' },
{ name: 'Nikki', cohort: 'June' },
{ name: 'Boris', cohort: 'June '}
];
for (const student of students) {
console.log(`name: ${ student.name }, cohort: ${ student.cohort }`)
}
const users = {
employees: [
{'first_name': 'Miguel', 'last_name' : 'Jones'},
{'first_name' : 'Ernie', 'last_name' : 'Bertson'},
{'first_name' : 'Nora', 'last_name' : 'Lu'},
{'first_name' : 'Sally', 'last_name' : 'Barkyoumb'}
],
managers: [
{'first_name' : 'Lillian', 'last_name' : 'Chambers'},
{'first_name' : 'Gordon', 'last_name' : 'Poe'}
]
};
for(const key in users){
console.log(key.toUpperCase());
for(let i = 0; i < users[key].length; i++){
const num = i + 1;
const fname = users[key][i].first_name;
const lname = users[key][i].last_name;
const length = fname.length + lname.length;
console.log(`${num} - ${lname}, ${fname} - ${length}`);
}
}
</script>
</body>
</html>