This mini-project will help you practice writing loops which you learned in the OC course here. Loops are tricky so be prepared to spend a bit of time trying out different things until it works. Don't be afraid to experiment with the code.
Here are some additional practice problems that may be helpful:
-
Copy the
loop.html
file inSOURCE_FILES
toPROJECT_SUBMISSION
. -
First open the file you just copied (
PROJECT_SUBMISSION/loop.html
) in your browser and open the Javascript console using Chrome Developer Tools. -
In the console output you should see
"Starter code is working"
. -
Add code that uses the
numLaughs
variable to construct a string of repeating "ha"'s. "ha" is repeated the number of times equal to whatever value is assigned tonumLaughs
. For example, in the code above since the value 4 is assigned, once your code is implemented correctly, the console should output "hahaha". If 2 was entered the output would be "haha", an so on. -
Test changing the value of
numLaughs
to make sure you get the correct string of "ha"'s. -
It's also a good idea to check what are called "edge cases". Make sure your code does not produce an error when you set
numLaughs = 0
. -
Extra credit: if you implemented this using a while loop, try implementing it again using a for loop, or vice versa.
-
Once you are happy with your code, create a new branch (e.g.
mini-project3.2a
), push your local changes to the branch (new file:loop.html
), then go to GitHub and create a new Pull Request and assign to your coach for review.