-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecommerceWebpage.html
More file actions
53 lines (43 loc) · 1.17 KB
/
ecommerceWebpage.html
File metadata and controls
53 lines (43 loc) · 1.17 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
<!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>
</body>
</html>
<script>
const cart=["shoes","pants","kurta"];
//To place an order
//1. Create a order
//2. Proceed to payment
//3. print order
// createOrder();
//because create order is asynchromer, there is possibility that it proceed to payments without creating order
// so, we use callback function
function showSummary(){
console.log("will show summary");
}
function createOrder(callback){
setTimeout(()=>{
console.log("order created");
callback();
},3*1000);
}
createOrder(function(){
proceedToPayment(function(){
showSummary();
});
})
function proceedToPayment(callback){
setTimeout(()=>{
console.log("payment");
callback();
},3000);
}
//callback Hell or Pyramid of Doom
//2. Inversion of Control: Does not have sureity that it will work
</script>