I want to print the err
variable to the payment Id if downtimeTotal
is NaN or null or 0 (so essentially if the user doesn't put any inputs) but the calculator still prints NaN.
<div class="totalwrapper">Credit Total:$<span id="payment" class="output"></span></div>
</div>
<button id="btn">Calculate</button>
<script>
let btn = document.getElementById('btn')
btn.addEventListener('click', function(){
let err = "you didn't put any numbers in!"
let rmr = document.getElementById('RMR').value;
let cam = document.getElementById('bcam').value;
let sens = document.getElementById('sensors').value;
let dayMonth = document.getElementById('days').value;
let bSensors = document.getElementById('badSensors').value;
let down = document.getElementById('daysDown').value;
let rmrCam = cam * 5 / dayMonth * down;
let getDowntime = rmr / sens / dayMonth * bSensors * down + rmrCam;
if (sens == 0 || NaN || null ) {
getDowntime = rmr / dayMonth * bSensors * down + rmrCam;
}
let downtimeTotal = getDowntime.toFixed(2)
if (downtimeTotal == NaN || null || 0.00){
document.getElementById("payment").innerHTML = err;
}else {
document.getElementById("payment").innerHTML = downtimeTotal;
}
})
</script>