-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsObjects.html
50 lines (45 loc) · 1.57 KB
/
jsObjects.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
<!DOCTYPE html>
<html>
<head>
<title>JS Objects</title>
<script type="text/javascript">
// Challenge 1
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 }`)
};
// Challenge 2
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>
</head>
<body>
</body>
</html>