-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBinToDec.html
34 lines (30 loc) · 1.2 KB
/
BinToDec.html
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">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./BinToDec.css">
<title>Document</title>
</head>
<body>
<h1>BINARY TO DECIMAL CONVERTER</h1>
<button id="attack">CLICK TO SHOW PROMPT</button>
<script type="text/javascript" src="./BinToDec.js"></script>
<script>
document.getElementById("attack").addEventListener("click", inuin);
function inuin() {
let uin = prompt("Please enter base2 number: ");
//try-catch-finally statement to attempt carrying out the conversion using the defined functions
try {
alert(bintodec(uin));
} catch (e) { //incase exception is thrown by try statement, pass it to a parameter 'e' to handle it
if (e instanceof TypeError) alert("You chose to abort.");
else alert(e);
} finally {
alert("Thank you for using this application! \u{1F604}"); //Thanking the user for using the application
}
}
</script>
</body>
</html>