Skip to content

Instantly share code, notes, and snippets.

@DestinyLuong
Created October 2, 2017 17:33
Show Gist options
  • Save DestinyLuong/ec8590f4bb2c98c1babc3644ffe6897a to your computer and use it in GitHub Desktop.
Save DestinyLuong/ec8590f4bb2c98c1babc3644ffe6897a to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=ec8590f4bb2c98c1babc3644ffe6897a
<!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"],"hiddenUIComponents":["editor.css"]}
// 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 === 0) {
$("#message").html("That’s zero feet.");
} else if (userNumber > 12) {
$("#message").html("More than a foot.");
} else if (userNumber < 12) {
$("#message").html("Less than a foot.");
} else {
$("#message").html("Exactly one foot.");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment