Question: Add one more button for division but check if the second (data2) value is non-zero. If zero, show the message invalid input on the message
Add one more button for division but check if the second (data2) value is non-zero. If zero, show the message invalid input on the message div, otherwise show the result of the data1/data2
document.querySelector('#division').addEventListener('click',
function(){
let data1Value = parseInt(data1.value);
let data2Value = parseInt(data2.value);
let total = data1Value / data2Value;
message.innerHTML = total;
});
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
