-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp41.html
More file actions
45 lines (36 loc) · 789 Bytes
/
p41.html
File metadata and controls
45 lines (36 loc) · 789 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
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Try catch</title>
</head>
<body>
<script type="text/javascript">
var x = prompt("Enterr your age: ", "");
try {
if(x>18){
throw 'Err1';
}
else if(x<18){
throw 'Err2';
}
else if(isNaN(x)){
throw 'Err3';
}
}
catch (err) {
if(err=='Err1'){
num = 12.03247896
alert("you are adult");
alert(num.toFixed(2))
}
if(err=='Err2'){
alert("you are young");
}
if(err=='Err3'){
alert("your input is not a number");
}
}
</script>
</body>
</html>