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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!