Skip to content

Instantly share code, notes, and snippets.

@dursk
Created March 23, 2017 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dursk/e9f55c7a26e234ccfb45426fed776be1 to your computer and use it in GitHub Desktop.
Save dursk/e9f55c7a26e234ccfb45426fed776be1 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=e9f55c7a26e234ccfb45426fed776be1
<!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>
// Write a function called isOldEnough that takes in two parameters:
// 1. The movie rating that is selected.
// 2. The age entered.
// The function should then check if the person is old enough
// and return true or false.
//
// Age brackets:
// G: ages 0 and older
// PG: ages 3 and older
// PG-13: ages 13 and older
// R: ages 17 and older
//
// When you click the button, you should use jQuery to get the rating and the age,
// and then call the isOldEnough function. Then in #response, you should insert
// "Yes" or "No" based on what isOldEnough returned.
.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