Skip to content

Commit 3ea4f60

Browse files
committed
lottery ticket exp
1 parent 91f71bf commit 3ea4f60

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"arrowParens": "avoid"
4+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
7+
<title>Understanding Async JavaScript Behind the Scenes</title>
8+
<style>
9+
body {
10+
height: 100vh;
11+
display: flex;
12+
align-items: center;
13+
background: linear-gradient(to top left, #28b487, #7dd56f);
14+
}
15+
h1 {
16+
font-family: sans-serif;
17+
font-size: 50px;
18+
line-height: 1.3;
19+
width: 100%;
20+
padding: 30px;
21+
text-align: center;
22+
color: white;
23+
}
24+
</style>
25+
<script defer src="script.js"></script>
26+
</head>
27+
<body>
28+
<h1>Understanding Async JavaScript Behind the Scenes</h1>
29+
</body>
30+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
//Biulding a new Promise
4+
const lotteryReq = new Promise(function (resolve, reject) {
5+
console.log('Checking The Results......');
6+
setTimeout(() => {
7+
if (Math.random() < 0.5) {
8+
resolve('You WIN 💰');
9+
} else {
10+
reject(new Error('You LOST Please Try Again 😢'));
11+
}
12+
}, 2000)
13+
14+
});
15+
16+
lotteryReq.then(res => console.log(res)).catch(err => console.error(err));

0 commit comments

Comments
 (0)