0
Why it returns infinity
1 Antwort
+ 4
Varin , This is the correct code that you want.
const distance = document.getElementById("distance")
const time = document.getElementById("Time")
const caculate = document.getElementById('result')
const distance_caculate = document.getElementById("distance-caculate")
const speed = document.getElementById('speed')
const time_caculate = document.getElementById('time-caculate')
let d, s
window.onload = () => {
caculate.onclick = function(){
d = parseInt(distance.value)
s = parseInt(time.value)
console.log(d/s)
}
time_caculate.addEventListener("click", e => {
d = parseInt(distance.value)
s = parseInt(time.value)
console.log(d/s)
})
}