forked from jetbreed/ES6_Basics_JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
destructuring1.html
63 lines (55 loc) · 1.97 KB
/
destructuring1.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
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
class MMS{
semester1;
semester2;
semester3;
semester4;
constructor(semester1, semester2, semester3, semester4){
this.semester1 = semester1;
this.semester2 = semester2;
this.semester3 = semester3;
this.semester4 = semester4;
}
}
logics = (semester1, semester2, semester3, semester4) => {
var sum = semester1 + semester2 + semester3 + semester4;
const avg = sum / 4;
const product = semester1 * semester2 * semester3 * semester4;
return [sum, avg, product];
}
//Constructor Instantiation
const mms = new MMS(190000, 190000, 190000, 190000);
const [sum, avg, product] = logics(mms.semester1, mms.semester2, mms.semester3, mms.semester4);
document.writeln("Sum: "+ sum);
document.writeln("<br>");
document.writeln("Average: "+ avg);
document.writeln("<br>");
document.writeln("Product: "+ product);
document.writeln("<br>");
document.writeln("Semester1: "+ mms.semester1);
document.writeln("<br>");
document.writeln("Semester2: "+ mms.semester2);
document.writeln("<br>");
document.writeln("Semester3: "+ mms.semester3);
document.writeln("<br>");
document.writeln("Semester4: "+ mms.semester4);
document.writeln("<br>");
document.writeln("<br>");
</script>
</body>
</html>
*ASSIGNMENT*
1. Merge all the above functions into one.
2. Use *DESTRUCTURING METHOD* to dissect your
answers.
3. Without distorting the output, print out
all the individual results.