Skip to content

Instantly share code, notes, and snippets.

@kudapara
Created April 3, 2019 12:05
Show Gist options
  • Save kudapara/b5aa1eac9f849b0bc76159603114b044 to your computer and use it in GitHub Desktop.
Save kudapara/b5aa1eac9f849b0bc76159603114b044 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Comparison in javascript</title>
</head>
<body>
After making the comparison
</body>
<script>
// Convert to integer from string so that the comparison
// is correct for cases like 12 being seen as less that 4
var a = parseInt(prompt("Insert the first number"));
var b = parseInt(prompt("Insert the second number"));
if (a > b) {
document.write(a + " is greater than " + b);
} else if (a < b) {
document.write(a + " is less than " + b);
} else {
document.write("they are equal");
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment