function compare() {
var value1 = parseInt(document.getElementById("box3").value);
var value2 = parseInt(document.getElementById("box4").value);
var display = document.getElementById("box5");
if (value1 === 0 || value2 === 0) {
display.value = "You have entered zero";
} else if (value1 == value2) {
display.value = "The numbers are the same";
} else if (value1 % value2 == 0) {
display.value = "The first is divisible by the second";
} else if (value2 % value1 == 0) {
display.value = "The second is divisible by the first";
} else {
display.value = "They are not divisible";
}
}
<p> Enter two numbers and we will inform you about their divisibility</p>
<p> Enter your first number:</p> <input type="text" id="box3">
<p> Enter your second number: </p> <input type="text" id="box4">
<button id="compareValue" onclick="compare()">Compare Values</button>
<p> Output will appear here: </p> <input text="type" id="box5" disabled>
In the code above, inputting 89.09 into the first number field and 0.05 into the second number field. Clicking on compare values results in:
You have entered zero
https://i.sstatic.net/XCoNc.jpg
The question remains, why?