-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
201 lines (165 loc) · 4.33 KB
/
main.js
File metadata and controls
201 lines (165 loc) · 4.33 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//------------------- Assignment 1 -------------------
function assign_1() {
let myNumbers = [1, 2, 3, 4, 5];
let [a, , , , e] = myNumbers;
console.log(a * e); // 5
}
assign_1();
console.log("");
//------------------- Assignment 2 -------------------
function assign_2() {
let mySkills = [
"HTML",
"CSS",
"JavaScript",
["PHP", "Python", ["Django", "Laravel"]],
];
let [a, b, c, [d, e, [f, g]]] = mySkills;
console.log(`My Skills: ${a}, ${b}, ${c}, ${d}, ${e}, ${f}, ${g}`);
// My Skills: HTML, CSS, JavaScript, PHP, Python, Django, Laravel
}
assign_2();
console.log("");
//------------------- Assignment 3 -------------------
// Solution 1
function assign_3_Method_1() {
let arr1 = ["Ahmed", "Sameh", "Sayed"];
let arr2 = ["Mohamed", "Gamal", "Amir"];
let arr3 = ["Haytham", "Shady", "Mahmoud"];
let [[c, ,], [, ,], [, a, b]] = [arr1, arr2, arr3];
console.log(`My Best Friends: ${a}, ${b}, ${c}`);
// My Best Friends: Shady, Mahmoud, Ahmed
}
assign_3_Method_1();
// Solution 2
function assign_3_Method_2() {
let arr1 = ["Ahmed", "Sameh", "Sayed"];
let arr2 = ["Mohamed", "Gamal", "Amir"];
let arr3 = ["Haytham", "Shady", "Mahmoud"];
let myFriends = arr1.concat(arr2, arr3);
let [c, , , , , , , a, b] = myFriends;
console.log(`My Best Friends: ${a}, ${b}, ${c}`);
// My Best Friends: Shady, Mahmoud, Ahmed
}
assign_3_Method_2();
console.log("");
//------------------- Assignment 4 -------------------
function assign_4() {
const member = {
age: 30,
working: false,
country: "Egypt",
hobbies: ["Reading", "Swimming", "Programming"],
};
const {
age: a,
working: w,
country: c,
hobbies: [h1, , h3],
} = member;
console.log(`My Age Is ${a} And Iam ${w ? "" : "Not"} Working`);
// My Age Is 30 And Iam Not Working
console.log(`I Live in ${c}`);
// I Live in Egypt
console.log(`My Hobbies: ${h1} And ${h3}`);
// My Hobbies: Reading And Programming
}
assign_4();
console.log("");
//------------------- Assignment 5 -------------------
function assign_5() {
const game = {
title: "YS",
developer: "Falcom",
releases: {
"Oath In Felghana": ["USA", "Japan"],
"Ark Of Napishtim": {
US: "20 USD",
JAP: "10 USD",
},
Origin: "30 USD",
},
};
const {
title: t,
developer: d,
releases: {
["Oath In Felghana"]: [u, j],
["Ark Of Napishtim"]: { US: u_price, JAP: j_price },
Origin: or,
},
} = game;
const [o, a] = Object.keys(game.releases);
console.log(`My Favourite Games Style Is ${t} Style`);
// My Favourite Games Style Is YS Style
console.log(`And I Love ${d} Games`);
// And I Love Falcom Games
console.log(`My Best Release Is ${o} It Released in ${u} & ${j}`);
// My Best Release Is Oath In Felghana It Released in USA & Japan
console.log(`Although I Love ${a}`);
// Although I Love Ark Of Napishtim
console.log(`${a} Price in USA Is ${u_price}`);
// Ark Of Napishtim Price in USA Is 20 USD
console.log(`${a} Price in Japan Is ${j_price}`);
// Ark Of Napishtim Price in Japan Is 10 USD
console.log(`Origin Price Is ${or}`);
// Origin Price Is 30 USD
}
assign_5();
console.log("");
//------------------- Assignment 6 -------------------
function assign_6() {
let chosen = 1;
let myFriends = [
{ title: "Osama", age: 39, available: true, skills: ["HTML", "CSS"] },
{ title: "Ahmed", age: 25, available: false, skills: ["Python", "Django"] },
{ title: "Sayed", age: 33, available: true, skills: ["PHP", "Laravel"] },
];
// Write Your Code Here
if (chosen === 1) {
let [
{
title: t,
age: ag,
available: av,
skills: [, lastSkill],
},
{},
{},
] = myFriends;
show(t, ag, av, lastSkill);
}
if (chosen === 2) {
let [
{},
{
title: t,
age: ag,
available: av,
skills: [, lastSkill],
},
{},
] = myFriends;
show(t, ag, av, lastSkill);
}
if (chosen === 3) {
let [
{},
{},
{
title: t,
age: ag,
available: av,
skills: [, lastSkill],
},
] = myFriends;
show(t, ag, av, lastSkill);
}
function show(t, ag, av, lastSkill) {
console.log(t);
console.log(ag);
console.log(`${av ? "" : "Not "}Available`);
console.log(lastSkill);
}
}
assign_6();