Skip to content

Instantly share code, notes, and snippets.

@AminBusiness
Created June 13, 2018 18:39
Show Gist options
  • Save AminBusiness/686256bc52ad43c7575e1a6420d2f146 to your computer and use it in GitHub Desktop.
Save AminBusiness/686256bc52ad43c7575e1a6420d2f146 to your computer and use it in GitHub Desktop.
// source https://jsbin.com
//Problem that accepts two answers and displays largest one
var num1, num2;
num1 = window.prompt("Input the First integer", "0");
num2 = window.prompt("Input the second integer", "0");
if(parseInt(num1, 10) > parseInt(num2, 10))
{
console.log("The larger of "+ num1+ " and "+ num2+ " is "+ num1+ ".");
}
else
if(parseInt(num2, 10) > parseInt(num1, 10))
{
console.log("The larger of "+ num1+" and "+ num2+ " is "+ num2+ ".");
}
else
{
console.log("The values "+ num1+ " and "+num2+ " are equal.");
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
//Problem that accepts two answers and displays largest one
var num1, num2;
num1 = window.prompt("Input the First integer", "0");
num2 = window.prompt("Input the second integer", "0");
if(parseInt(num1, 10) > parseInt(num2, 10))
{
console.log("The larger of "+ num1+ " and "+ num2+ " is "+ num1+ ".");
}
else
if(parseInt(num2, 10) > parseInt(num1, 10))
{
console.log("The larger of "+ num1+" and "+ num2+ " is "+ num2+ ".");
}
else
{
console.log("The values "+ num1+ " and "+num2+ " are equal.");
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">//Problem that accepts two answers and displays largest one
var num1, num2;
num1 = window.prompt("Input the First integer", "0");
num2 = window.prompt("Input the second integer", "0");
if(parseInt(num1, 10) > parseInt(num2, 10))
{
console.log("The larger of "+ num1+ " and "+ num2+ " is "+ num1+ ".");
}
else
if(parseInt(num2, 10) > parseInt(num1, 10))
{
console.log("The larger of "+ num1+" and "+ num2+ " is "+ num2+ ".");
}
else
{
console.log("The values "+ num1+ " and "+num2+ " are equal.");
}</script></body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment