ALFT: M5L1 - Welcome to JavaScript - Lab Assignment

Your school needs a site to keep track of scores during basketball games. There is some prewritten Javascript that will make the counter work once you create the needed variables.

Create the following variables to make the counter work.

First, let's give our teams names. Declare two variables called teamOneName and teamTwoName. Give them both a value with names of your choosing.

Then, we'll need variables to keep track of team scores. Declare two more variables - scoreOne and scoreTwo. Assign them each a starting value of 0.

Now, let's give the shot buttons values.

  • Declare a variable freeThrow. Assign it a value of 1 - this is how many points will be added to the score when the free throw button is clicked.
  • Declare a variable twoPointShot. Assign it a value of 2 - this is how many points will be added to the score when the 2 point button is clicked.
  • Declare a variable threePointShot. Assign it a value of 3 - this is how many points will be added to the score when the 3 point button is clicked.

Check and see if the buttons work!

Done early?

Update the score so team two starts at 3 points.

Scroll down to the prewritten Javascript. Update the updateScore function so it SUBTRACTS points every time a button is clicked instead of adding.

Declare a new variable called arena. Give it a value of your choice. Use JavaScript to replace the heading of your webpage with your arena name.