-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects.js
71 lines (66 loc) · 1.47 KB
/
objects.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const Patryk = {
name: "Patryk",
age: 23,
job: "Customer Advisor",
hobbies: ["Games", "Music", "esports"],
pets: ["Cat", "Dog"]
}
const Agustina = {
name: "Agustina",
age: 33,
job: "Senior consultant for AOC",
hobbies: ["books", "series", "movies"],
pets: [
{
name: "Paco",
species: "Russian Blue Black"
}
],
}
const Mike = {
name: "Michael",
age: 36,
job: "Mortgage Advisor",
hobbies: ["leeds united"],
pets: ["luna"]
}
const Lucy = {
name: "Lucy",
age: 22,
job: "Banking consultant",
hobbies: ["Games", "Music", "baking"],
pets: ["Cat", "Hamster"]
}
const Leo = {
name: 'Leo',
age: 35,
job: 'Support Analyst',
hobbies: ['Gaming', 'Gym', 'More Gaming'],
pets: ['Whiskas']
}
const people = [Patryk, Agustina, Mike, Lucy, Leo]
for (const person of people) {
console.log(
"Name:", person.name,
"Age:", person.age,
"Job:", person.job,
"Hobbies:", person.hobbies,
"pets", person.pets,
);
}
let oldest = { age: 0 };
for (const person of people) {
if (person.age > oldest.age){
{ oldest.age = person.age };
(oldest.name = person.name)
}
}
console.log("Oldest:", oldest);
let youngest = { age: 999 };
for (const person of people) {
if (person.age < youngest.age){
{youngest.age = person.age};
(youngest.name = person.name)
}
}
console.log("Youngest:", youngest);