-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
52 lines (41 loc) · 1.45 KB
/
Copy pathscript.js
File metadata and controls
52 lines (41 loc) · 1.45 KB
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
const userInput1 = document.getElementById("num1-el");
const userInput2 = document.getElementById("num2-el");
const result = document.getElementById("result");
const error = document.getElementById("error");
const resetButton = document.getElementById("reset");
function add() {
let updatedUserInput1 = Number(userInput1.value);
let updatedUserInput2 = Number(userInput2.value);
let total = updatedUserInput1 + updatedUserInput2;
result.textContent = `Result is ${total}`;
}
function Subtract() {
let updatedUserInput1 = Number(userInput1.value);
let updatedUserInput2 = Number(userInput2.value);
total = updatedUserInput1 - updatedUserInput2;
result.textContent = `Result is ${total}`;
}
function Divide() {
let updatedUserInput1 = Number(userInput1.value);
let updatedUserInput2 = Number(userInput2.value);
error.textContent = "";
if (updatedUserInput2 === 0) {
error.textContent = "You can't divide by 0";
return;
}
total = updatedUserInput1 / updatedUserInput2;
result.textContent = `Result is ${total}`;
}
function Multiply() {
let updatedUserInput1 = Number(userInput1.value);
let updatedUserInput2 = Number(userInput2.value);
total = updatedUserInput1 * updatedUserInput2;
result.textContent = `Result is ${total}`;
}
function reset() {
error.textContent = "";
userInput1.value = "";
userInput2.value = "";
result.textContent = "";
dogCounter.textContent = `Result is__`;
}