Goal: In the Branching video, we learned:
- How to use an
if..else statement to add logic to our webpages.
- The difference between
You will use branching very often moving forward, no matter which programming language(s) you opt to explore in the future. Get the hang of basic branching now by completing the exercises listed below.
- When do we use
===? When do we use
= instead? What is the difference between the two?
- How many
if statements can one branch have?
- How many
else statements may one branch contain?
- Under what circumstances does an
else statement execute?
Create a page that offers users information about the voting process.
- The page should prompt the user to enter their current age.
- If the user is too young to vote, they should see different information than if the user is old enough to legally vote.
- Minors should be offered links to websites where they may learn about the voting process and age requirements.
- Those old enough to vote should be offered links to websites to register to vote, locate their nearest polling location/ballot dropbox is, or list when upcoming elections will take place.
Craft a site with information about turtles, snakes, and insects (or another three animals or items of your choosing).
- The page should ask the user which animal they'd like to learn about.
- When a user clicks an animal, display a div containing information about that animal (including pictures!).
- If they later select a different animal, make sure to hide this div before displaying information about another animal.
- Create a website for an amusement park that prompts the user to enter their height.
- The page should then only displays information about rides the user is tall enough to safely ride.
- Then, try showing a list of all rides and just highlighting (with CSS) the ones the user may safely ride.
- (Make sure there are some rides that an adult can't go on because they are too tall!)