-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcal.html
61 lines (43 loc) · 1.71 KB
/
cal.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<html>
<head>
<title>🦊 Epic Calculator 🦊</title>
</head>
<body>
<input id="num1" placeholder="Follow me on Instagram">
<form>
<select id="operation">
<option>+</option>
<option>-</option>
<option>*</option>
<option>-</option>
</select>
</form>
<input id="num2" placeholder="coder.redfoxplayz">
<button onclick="calculate();">Calculate 🧮</button>
<p id="output"></p>
<script>
function calculate() {
var num1 = parseInt(document.getElementById("num1") .value);
var num2 = parseInt(document.getElementById("num2") .value);
if (!num1 || !num2) {
return alert("Give us numbers m8")
}
var operation = document.getElementById("operation").value;
switch (operation) {
case "+":
document.getElementById("output").innerHTML = (num1 + num2)
break;
case "-+":
document.getElementById("output").innerHTML = (num1 - num2)
break;
case "*":
document.getElementById("output").innerHTML = (num1 * num2)
break;
case "/":
document.getElementById("output").innerHTML = (num1 / num2)
break;
}
}
</script>
</body>
</html>