diff --git a/index.html b/index.html
index fdb306537..a45b9ffcb 100644
--- a/index.html
+++ b/index.html
@@ -3,6 +3,7 @@
+
Document
diff --git a/index.js b/index.js
index c2cac5161..f290fd469 100644
--- a/index.js
+++ b/index.js
@@ -28,10 +28,21 @@ function processFirstItem(stringList, callback) {
*
* 1. What is the difference between counter1 and counter2?
*
+ *
+ * Counter 1 has a local variable inside its function that can not be accessed outside the function.
+ * Counter 2 uses a global variable inside its function to
+ *
* 2. Which of the two uses a closure? How can you tell?
*
+ * The second uses a closure. It has a variable that it calls upon that is directly inside its function,
+ * and it also executes the function with return. The first one does not complete a function as there is
+ * no return command.
+ *
* 3. In what scenario would the counter1 code be preferable? In what scenario would counter2 be better?
- *
+ *
+ * Counter1 would be preferable if the count variable is not to be used ever again in the script. We want
+ * to keep the code as clean as possible. We don't want a variable hanging out with no purpose.
+ * The counter2 code would be useful if we plan on using the count variable down the line in our code.
*/
// counter1 code
@@ -57,10 +68,12 @@ function counter2() {
Write a function called `inning` that generates a random number of points that a team scored in an inning. This should be a whole number between 0 and 2. */
function inning(/*Code Here*/){
+ const randomScore = Math.floor(Math.random() * 3);
+ return randomScore;
+ }
- /*Code Here*/
+console.log(inning());
-}
/* Task 3: finalScore()
@@ -76,11 +89,28 @@ finalScore(inning, 9) might return:
*/
-function finalScore(/*code Here*/){
+function finalScore(inning, num){
+
+ let score1 = 0;
+ let score2 = 0;
+
+ for(let i = 0; i < num; i++){
+ score1 = score1 + inning()
+ score2 = score2 + inning()
+ }
+
+
+ let inningCount =
+ {
+ home: score1,
+ away: score2,
+ }
- /*Code Here*/
+ return inningCount;
+};
-}
+console.log(finalScore(inning, 9))
+
/* Task 4:
@@ -104,8 +134,15 @@ and returns the score at each pont in the game, like so:
Final Score: awayTeam - homeTeam */
-function scoreboard(/* CODE HERE */) {
- /* CODE HERE */
-}
+function scoreboard(getInningScore, whichInning, num) {
+ let twoScores = [];
+ for(let i = 0; i < num; i++){
+ twoScores.push(`Innings ${i+1}: ${getInningScore(whichInning, 1)}`);
+ }
+ return twoScores;
+ }
+
+console.log(scoreboard(finalScore, inning, 9));
+