-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallbackAsynchronous.js
More file actions
38 lines (37 loc) · 1.13 KB
/
callbackAsynchronous.js
File metadata and controls
38 lines (37 loc) · 1.13 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
//Problem: Make a process that can calculate a student course progress
//In this processs you can define 3 situation such as "pyment, study progress, getting certificate"
{
const studentPayment = true;
const studentMarks = 90;
function payment(callback1) {
console.log(`Payment on progress!`);
setTimeout(function () {
if(studentPayment === true) {
callback1();
}
else {
console.log(`Payment failed! try again later :(`);
}
}, 2000)
}
function progress(callback2) {
console.log(`Course on progress.....`);
setTimeout(function () {
if(studentMarks >= 80) {
callback2();
}
else {
console.log(`Not enough marks to get your certificate.`);
}
}, 3000)
}
function getCertificate() {
console.log(`Preparing your certificate>>>>>`);
setTimeout(function () {
console.log(`Congratulations! We feel proud of you.`);
}, 1000)
}
payment(function (){
progress(getCertificate)
})
}