-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex-7.html
105 lines (95 loc) · 2.39 KB
/
index-7.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
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
<!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">
<meta name="keywords" content="Objects">
<title>Coding Assisement</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<h2>7. Objects</h2>
<!-- ====== write code -->
<div class="Que">
<p>Que.1 Create a Function</p>
<pre>
function Check(obj1){
obj1.setter = function() {
console.log(obj1.name);
}
}
</pre>
<p>Que.2 Delete a Parameter</p>
<pre>
function Check(obj1, rollno) {
// Check if the object has the `rollno` property
if (obj1.hasOwnProperty("rollno") && obj1.rollno === rollno) {
// Delete the `rollno` property
delete obj1.rollno;
return true;
} else {
return false;
}
}
</pre>
<p>Que.3 Check whether the Package is Dream Package or not</p>
<pre>
function Check(obj1) {
if (obj1.salary > 500000) {
return "Dream";
} else {
return "NotDream";
}
}
</pre>
<p>Que.4 Check whether the Object has a parameter or not</p>
<pre>
function Check(obj1) {
if (Object.keys(obj1).length === 0) {
return false;
} else {
return true;
}
}
</pre>
<p>Que.5 Merge the Objects</p>
<pre>
function Check(obj1,obj2) {
return {
name: obj1.name,
id: obj1.id,
state: obj2.state,
code: obj2.code
};
}
</pre>
<p>Que.6 Object Multiplyer</p>
<pre>
function Check(a,{id, houseno}) {
return { id: id * a, houseno: houseno * a };
}
</pre>
<p>Que.7 Find the sum of Object Members</p>
<pre>
function Check({ p1, p2, p3 }) {
return p1 + p2 + p3;
}
</pre>
<p>Que.8 Check whether the Objects are same or not.</p>
<pre>
function check(obj1,a,b) {
if (obj1.name === a && obj1.id === b) {
return true;
} else {
return false;
}
}
</pre>
</div>
<div class="container">
<div class="row"><a href="./index-6.html">Back</a></div>
<div class="row"><a href="./index-8.html">Next</a></div>
</div>
</body>
</html>