I'm learning JavaScript, and I'm trying to improve the code from an example from Beginning JavaScript. Specifically, I'm trying to get the code to check if an ending value is greater than the start value.
If I enter a starting value of 50 and an ending value of 6 or 8, then I get false for end <= start, even though both 6 and 8 are less than 50. If I enter any other value less than 50, I get true. I have the same problem with any starting value I've tested. I cannot find any error in the logic, so I must be misunderstanding the code (or just blind).
Thank you!
<body>
<script>
while (isNaN(start) == true) {
var start = prompt("Enter starting value", "");
}
while (isNaN(end) || end <= start) {
var end = prompt("Enter ending value", "");
document.write((end <= start) + "<br/>");
document.write(start + "<br/>");
document.write(end + "<br/>");
}
</script>
</body>