Skip to content

Instantly share code, notes, and snippets.

@LtAstros
Created October 3, 2017 14:48
Show Gist options
  • Save LtAstros/08602df5f82a63d8cbb5393e267af0d1 to your computer and use it in GitHub Desktop.
Save LtAstros/08602df5f82a63d8cbb5393e267af0d1 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=08602df5f82a63d8cbb5393e267af0d1
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h3>How many inches tall are you?</h3>
<input><button>Analyze</button>
<p id="message"></p>
</body>
</html>
{"enabledLibraries":["jquery"]}
// Modify the below code so that it checks to see if the user entered a number greater or less than 12
//
// If the number is greater than 12, write "More than a foot" to the page
// If the number is less than 12, write "Less than a foot" to the page
// Otherwise, write "Exactly one foot" to the page
$("button").click(function() {
var userNumber = parseInt($("input").val());
if (userNumber > 12) {
$("#message").html("More than a foot");
} else if (userNumber === 12) {
$("#message").html("Exactly one foot");
} else {
$("#message").html("Less than a foot");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment