Skip to content

Commit 628b84a

Browse files
Balashov NikitaOlegLustenko
authored andcommitted
classwork-10
1 parent 95e5670 commit 628b84a

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Class work 10</title>
6+
</head>
7+
<body>
8+
<script src="src/main.js"></script>
9+
</body>
10+
</html>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Task 1
2+
3+
const cafe = {
4+
name: `fellowship of the ring`,
5+
fruits: `apple, orange, watermelon`,
6+
showFruits() {
7+
return this.fruits;
8+
},
9+
showPartnerFruits: showPartnerFruits,
10+
partners: [
11+
{
12+
name: `Frodo`,
13+
fruits: [`pineapple`, `nuts`]
14+
},
15+
{
16+
name: `Boromir`,
17+
fruits: [`sword`, `axe`]
18+
},
19+
{
20+
name: `Gendalf`,
21+
fruits: [`beard`, `chair`]
22+
},
23+
],
24+
}
25+
26+
function showPartnerFruits() {
27+
const partners = this.partners;
28+
partners.forEach((elem) => {
29+
console.log(this.showFruits.call(elem))
30+
})
31+
}
32+
cafe.showPartnerFruits();
33+
console.log(cafe.showFruits());
34+
35+
const teacher = {
36+
teacherName: 'Alla Ivanovich',
37+
}
38+
39+
const someMagic = {
40+
someMagic(){
41+
console.log(`ХАЛЯВА ПИРИДИ`);
42+
}
43+
}
44+
45+
const students = [];
46+
47+
function makeStudents(arr, quantity) {
48+
for(let i = arr.length; i < quantity; i++) {
49+
const template = {
50+
name: `studen ${i + 1}`,
51+
}
52+
arr.push(template);
53+
}
54+
}
55+
56+
function addTeacher(arr) {
57+
arr.forEach((elem) => {
58+
elem.__proto__ = teacher;
59+
elem.teacher = elem.__proto__;
60+
});
61+
}
62+
63+
makeStudents(students, 30);
64+
addTeacher(students);
65+
66+
teacher.teacherName = `Boris Snowden`;
67+
console.log(students);
68+
69+
function addSomeMagic(arr) {
70+
arr.forEach((elem) => {
71+
elem.__proto__ = someMagic;
72+
elem.someMagic = elem.__proto__;
73+
});
74+
}
75+
76+
addSomeMagic(students);

0 commit comments

Comments
 (0)