-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (28 loc) · 1 KB
/
index.js
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
let num1 = 8
let num2 = 2
document.getElementById("num1-el").textContent = num1
document.getElementById("num2-el").textContent = num2
// Create four functions: add(), subtract(), divide(), multiply()
// Call the correct function when the user clicks on one of the buttons
// Perform the given calculation using num1 and num2
// Render the result of the calculation in the paragraph with id="sum-el"
// E.g. if the user clicks on the "Plus" button, you should render
// "Sum: 10" (since 8 + 2 = 10) inside the paragraph with id="sum-el"
let sumEl = document.getElementById("sum-el")
function add(){
let result = num1 + num2
sumEl.textContent = "Sum: " + result
}
function subtract(){
let result = num1 - num2
sumEl.textContent = "Sum: " + result
}
function divide(){
let result = num1 / num2
sumEl.textContent = "Sum: " + result
}
function multiply(){
let result = num1 * num2
sumEl.textContent = "Sum: " + result
}
console.log("28-02-2022")