WEEK: 4
Active: February 3rd - February 9th
Work Due: February 10th @ 11:59 PM

Homework

For your homework this week, you are changing how you handle input, using functions, and working with loops and controls structures. Now, you will give the user choices and depending on the choice entered into a text box, the next part of the story prints out. Expand your story to include at least five options. Create functions to handle input and return output. Use if, else if and else or switch statements to make decisions. In the end, ask the user if they want to start again.

For example, you might do something like this:

  1. You are driving down a dirt road heading nowhere in particular. You come to a T in the street. Which way do you go? Go left? Go Right?

  2. If the user types in Left, you can say something like, “You go to the Left and find a quaint restaurant in which you decide to stop and eat. You get some chicken fried steak.”

  3. If the user chooses Right, you can say something like, “You go to the right and drive for hours and hours and run out of fuel. You are lost and not sure what to do next.

  4. Those are the decisions, and you will update div tags or span tags depending on the choices they make.

  5. You will also update your styling and your images, depending on the decisions made. Before you say, “Whoa! You haven’t shown us that yet. You are right! However, if you remember how to access the DOM, getElementById, you can do the same thing by accessing your style tag. Hint check this out: Updating CSS from JavaScript

Specifics:

  1. Get user input from textboxes
  2. Have at least 5 different decisions in the story
  3. Use if, else if, else, and/or switch statements
  4. Use for, while or do-while loops
  5. Create and call functions that take parameters
  6. Have at least one function return a value.
  7. Update styles and images from your JavaScript.
  8. Allow the user to restart the story.

Homework 4 Example Video

Homework 4 Example

Due Feb 10, 2020 11:59 PM


Previous section:
Next section: