-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
30 lines (26 loc) · 851 Bytes
/
script.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
//Function to display the numbers
function insert(num) {
let number = document.getElementById('result').innerHTML
document.getElementById('result').innerHTML = number + num
}
//Function to clear the display
function clearDisplay() {
document.getElementById('result').innerHTML = ''
}
//Function to delete each number
function del() {
var result = document.getElementById('result').innerHTML
document.getElementById('result').innerHTML = result.substring(
0,
result.length - 1
)
//the substring method extracts characters between the start and the end (excluding the last one)
}
//Function to get the final result
function calculate() {
var result = document.getElementById('result').innerHTML
if (result) {
document.getElementById('result').innerHTML = eval(result).toFixed(2)
}
var result = parseFloat(result)
}