-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperators.html
More file actions
47 lines (36 loc) · 812 Bytes
/
operators.html
File metadata and controls
47 lines (36 loc) · 812 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
46
47
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
var input1 = 120;
var input2 = 0;
var operation = 'divide';
var result = 0;
function add(a, b) {
return a + b;
}
if (input1 === 0 || input2 === 0) {
console.log("Enter a value greater than 0!");
}
else {
if (operation == "add") {
result = add(input1, input2);
} else if (operation == "subtract") {
result = input1 - input2;
} else if (operation == "multiply") {
result = input1 * input2;
} else if (operation == "divide") {
result = input1 / input2;
} else {
result = "?";
}
console.log(result);
}
// var result = input1 - input2;
</script>
</head>
<body>
</body>
</html>