-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexercise4.html
More file actions
34 lines (31 loc) · 976 Bytes
/
exercise4.html
File metadata and controls
34 lines (31 loc) · 976 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Exercise #3</title>
<script type="text/javascript">
function fun(x, y, z) { // synchronous/blocking function
if (Math.random()<0.5){
throw "Something is wrong!";
}
return x * y + z ** 3;
}
// let result = fun(1, 2, 3);
// console.log(`result is ${result}.`);
async function gun(x, y, z) { // synchronous/blocking function
if (Math.random()<0.5){
throw "Something is wrong!";
}
return x * y + z ** 3;
}
gun(1,2,3).then( result => console.log(`result is ${result}.`))
.catch( e => console.error(e) );
async function sun(){
let anotherResult = await gun(1,2,3);
}
console.log("Application is running");
</script>
</head>
<body>
</body>
</html>