Que.1 Create a Function
function Check(obj1){ obj1.setter = function() { console.log(obj1.name); } }
Que.2 Delete a Parameter
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; } }
Que.3 Check whether the Package is Dream Package or not
function Check(obj1) { if (obj1.salary > 500000) { return "Dream"; } else { return "NotDream"; } }
Que.4 Check whether the Object has a parameter or not
function Check(obj1) { if (Object.keys(obj1).length === 0) { return false; } else { return true; } }
Que.5 Merge the Objects
function Check(obj1,obj2) { return { name: obj1.name, id: obj1.id, state: obj2.state, code: obj2.code }; }
Que.6 Object Multiplyer
function Check(a,{id, houseno}) { return { id: id * a, houseno: houseno * a }; }
Que.7 Find the sum of Object Members
function Check({ p1, p2, p3 }) { return p1 + p2 + p3; }
Que.8 Check whether the Objects are same or not.
function check(obj1,a,b) { if (obj1.name === a && obj1.id === b) { return true; } else { return false; } }