Created
March 23, 2017 00:59
-
-
Save dursk/8d60d63060b1e8c9eda41ddf1f47ff6f to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=8d60d63060b1e8c9eda41ddf1f47ff6f
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> | |
<h1>Movie Ratings</h1> | |
<div class="rating"> | |
<h3>Select a rating:</h3> | |
<input type="radio" name="rating" value="G"> G <br> | |
<input type="radio" name="rating" value="PG"> PG <br> | |
<input type="radio" name="rating" value="PG-13"> PG-13 <br> | |
<input type="radio" name="rating" value="R"> R <br> | |
</div> | |
<div class="age"> | |
<h3>Enter your age:</h3> | |
<input type="number" name="age"> | |
</div> | |
<div> | |
<button>Am I old enough to see the movie?</button> | |
<p id="response"></p> | |
</div> | |
</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"]} |
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
// Write two functions: | |
// One should be called isOldEnoughPG13 | |
// and the other should be isOldEnoughR. | |
// They should each take in one parameter named age. | |
// Each function should return true or false if the persons | |
// age is old enough to see the movie. | |
// When you click the button you should display "Yes" or "No" | |
// based on what the result is. | |
$("button").click(function() { | |
var rating = $("input[name=rating]:checked").val(); | |
var age = $("input[name=age]").val(); | |
var canSeeMovie; | |
if (rating === 'G') { | |
canSeeMovie = true; | |
} else if (rating === 'PG') { | |
canSeeMovie = true; | |
} else if (rating === 'PG-13') { | |
// Call a function and store the result. | |
} else if (rating === 'R') { | |
// Call a function and store the result. | |
} | |
if (canSeeMovie) { | |
$("#response").html('Yes'); | |
} else { | |
$('#response').html('No!'); | |
} | |
}); |
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
.rating input { | |
margin: 8px; | |
} | |
.age input { | |
height: 20px; | |
width: 50px; | |
} | |
button { | |
margin-top: 25px; | |
height: 30px; | |
font-size: 15px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment