-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexersiseFirst.js
More file actions
37 lines (34 loc) · 873 Bytes
/
Copy pathexersiseFirst.js
File metadata and controls
37 lines (34 loc) · 873 Bytes
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
// exersise using objects
// itemName
// price
// discount
// itemCode
let newObj={
itemName:"SmartPhone",
price : 20000,
discount:10,
itemCode : "NO1",
}
// Factory Function
function newObjF(item,priceArg,discount,itemcode){
return{
itemName:item,
price:priceArg,
discount:discount,
itemCode :itemcode,
}
}
const Laptop=newObjF("Laptop",100000,20,"LP1");
// Constructor Function
function NewObj(item,priceArg,discount,itemcode){
this.itemName=item;
this.price =priceArg;
this.discount=discount;
this.itemCode =itemcode;
thsi.discount_cal= function (){
temp=(priceArg*discount)/100;
console.log("Your Discount is :-",temp,`For the product${item}`);
console.log("Thanks for Shopping");
}
}
const Mobile= new NewObj("Oneplus",25000,5,"MB2");