Created
October 2, 2017 17:33
-
-
Save DestinyLuong/ec8590f4bb2c98c1babc3644ffe6897a to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=ec8590f4bb2c98c1babc3644ffe6897a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"enabledLibraries":["jquery"],"hiddenUIComponents":["editor.css"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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