From 177acd17bc6c40ecf46bbda03ded72d5835cd565 Mon Sep 17 00:00:00 2001 From: Billy G <10028885+GibzB@users.noreply.github.com> Date: Mon, 17 Apr 2023 15:04:41 +0300 Subject: [PATCH 1/2] Create app.js --- javascript/hungman/app.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 javascript/hungman/app.js diff --git a/javascript/hungman/app.js b/javascript/hungman/app.js new file mode 100644 index 00000000..776d216d --- /dev/null +++ b/javascript/hungman/app.js @@ -0,0 +1,38 @@ +// This is a one player hungman game + +// Global variables +var word = "hangman"; +var wordArray = word.split(""); +var wordLength = wordArray.length; +var guessArray = []; +var guessCount = 0; +var guessLimit = 6; +var guess = ""; + +// Create an array of underscores +for (var i = 0; i < wordLength; i++) { + guessArray[i] = "_"; + } + +// Create a function to check if the guess is correct +function checkGuess() { + for (var i = 0; i < wordLength; i++) { + if (wordArray[i] === guess) { + guessArray[i] = guess; + } + } +} + +// Create a function to check if the game is over +function gameOver() { + if (guessCount === guessLimit) { + console.log("Game Over"); + } +} + +// Create a function to check if the game is won +function gameWon() { + if (guessArray === wordArray) { + console.log("You won!"); + } +} From 6adcac95c019e464e7e67d3a0f8a27791c5c52c3 Mon Sep 17 00:00:00 2001 From: Billy G <10028885+GibzB@users.noreply.github.com> Date: Mon, 17 Apr 2023 15:05:32 +0300 Subject: [PATCH 2/2] Create index.html --- javascript/hungman/index.html | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 javascript/hungman/index.html diff --git a/javascript/hungman/index.html b/javascript/hungman/index.html new file mode 100644 index 00000000..58af4837 --- /dev/null +++ b/javascript/hungman/index.html @@ -0,0 +1,55 @@ + + + + + Hungman + + + +
+
+

Hungman

+
+
+
+ hangman +
+
+

Word

+

____

+
+
+

Letters

+ +
+
+
+ +