-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
38 lines (21 loc) · 1016 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
31
32
33
34
35
36
37
38
function compute() {
principal = document.getElementById("principal").value;
rate = document.getElementById("rate").value;
years = document.getElementById("years").value;
if (principal < 1) {
alert('Enter a positive number')
document.getElementById("principal").focus()
return
}
console.log(principal, rate, years)
actualYear = 2021 + Number(years)
interest = principal * years * rate / 100
console.log('interest', interest, actualYear)
document.getElementById("result").innerHTML =
'<p>If you deposit<span class="highlight" > ' + principal + '</span>, at an interest rate of <span class="highlight" > ' + rate + '%</span>.You will receive an amount of <span class="highlight" > ' + interest + '</span>,in the year <span class="highlight" > ' + actualYear + '</span></p>'
}
function slider(val) {
val = document.getElementById("rate").value;
document.getElementById("sliderValue").innerHTML = val
console.log(val)
}