For the midterm project you will be demonstrating your understanding JavaScript by creating a text-based word game called Scramble, where player must guess the word from a scramble of letters.
When the page loads, the player will be presented with a list of
instructions in the browser's console. The player can request these
instructions again at any time by using the help()
command. The
help()
function has been provided in the started files.
After the player starts the game, they will be given a scrambled word.
The player will be able to guess the correct spelling of the word using
the guess()
command. If correctly guessed the word the player will
receive a point. If guessed incorrectly, they player will receive a
strike.
A new word will not be displayed until player guesses correctly or the player passes on the work. If a player guesses correctly or passes on a word that word should not appear again during the game.
The player can skip a word by using the pass()
command. Passing on a
word will remove the word from the list, but the player will not receive
a point. The player can only pass a limited number of times.
The game ends when all words in the list have been guessed or after the player has received the maximum number of strikes.
After the games ends, the player will be present with a total number points earned for that game.
The following requirement must be met in order to complete the assignment successfully:
-
Clone this repository from GitHub and use the provided files to complete the assignment. The files contain
index.html
,style.css
, andscramble.js
. All changes for this assignment will be made to thescramble.js
file. -
Create a words array to hold the words that will be used in the game. To keep things simple do NOT include words with spaces or special characters. The array should include at least 10 words.
-
Create a game object. The game object will hold the current game's status including but not limited to:
- The game active status
- The random list of words
- The current word
- The current scrambled word
- The number of strikes
- The number of points
- The maximum number of allowed strikes
- The number of passes used
- The maximum number of passes
-
Create a
start()
function, which is used to start a new game, will do the following:- Reset all the game status properties
- Make a copy of the words array and store it in the game object
- Shuffle the words array copy. A shuffle function was provided in the starter files.
- Select a word from the shuffled array save to the game object.
- Display a scrambled version of the word to the player.
-
If a game currently active than a new game CANNOT be started.
-
Create a
guess()
function that will be used by the player to guess the word and will do the following:-
Check to see if the guessed word matches the current word unscrambled. Case should NOT matter.
-
If the words do match the player will receive a point. The word should be removed from the game list (the same word should not appear twice) and the next word should be displayed.
-
If the words do NOT match the player will receive a strike and the current word will be displayed again.
-
-
The player should NOT be able to make guesses if there is no active game.
-
Create a
pass()
function that will be used by the player to skip a word and will do the following:-
Check if player has any passes left
-
Remove the from the game list (the same word should not appear twice) and the next word should be displayed.
-
The player should NOT receive a point for passing.
-
-
The player should NOT be able to pass if there is no active game.
-
The game will end if there are no more words in the list OR the player has received the maximum number of strikes
-
When the game ends the player total points should be displayed.
-
After the game ends the player should be able to start a new game using the
start()
function.
The following screencast shows how to use the provided shuffle()
function.
Below are a few suggestions, recommendations, and answers to common questions on how to complete this project. This list will be updated as questions arise.
-
You may need more functions than just the ones used for the actions. For example, you may want a function that will get and scramble the next word.
-
You may want to work with all capital letters. It will simplify things when checking if a letter is in a puzzle. You can use string method
toUpperCase()
to convert a string to all capital letter. -
The string method
split()
will convert a string to array. -
The array method
join()
will convert an array to a string. -
The array method
slice()
can be used to make a copy of an array. -
The array methods
pop()
,shift()
, andsplice()
will return the item that was removed from an array.
The following video is an example of how a finished version of the assignment could look like.
When the project is completed, follow the steps below to submit for grading:
- Create a commit with the message "Completes the Scramble assignment"
- Push all commits to GitHub.
- Submit the URL to your GitHub repository to the Scramble assignment on BrightSpace.