A guessing game built with JavaScript. This is meant to be a practice for filtering arrays, decision trees, using RegEx and directing user flow.
View Deployed Application Here.
- Clone repository to your local device
- Open HTML in Default Browser and press button to play the game.
This repo is for practice and has an MIT License. Use it if you want!
Capitalize first letter of each word in an array of strings, answered by Jonas Wilms
Using new Set to filter non repeated data in an array JavaScript
How to split a string into an array of characters
MDN String.prototype.replace()
Currently the button simply generates a random president. However, it bases the President written to the screen off of the first index of an array. The array is created from a new list of Presidents containing one letter. The letter is chosen randomly from an array of letters. So, even though it's not as I want it, the president at least is generating in part from a new array generated by a random letter.
The next step will be to hide the Start button when pressed and comment out the code that writes a President to the screen. I want to build a loop that will ask a User if their President contains the letter ${letter} 5 times, so this will be made with a loop. It would help to create a new letter each time, so maybe test by writing the letter to the screen before the rest of the logic. At any rate, Once I loop and ask this question five times, the User presses Yes or No each time.
The User decides by yes or no, but the bulk of this project comes from functions that create new arrays. The methods such as filter and array are ones I will be using heavily, and the arrays used will at least be the President Array and the Letter Array.
The end goal is to filter Presidents down and letters down (so no repeat asks) until there are only a few (ideally 1) President left. The first index of that final array will be the computer's guess. After that, I want to write code for a list of President photos, and have the User answer yes or no for if we guessed correctly. If yes, a green checkmark over the photo, else a red X. At the end, a button should appear to ask the user if they want to play again.
Enhance: I believe that if I could generate an array of letters (no repeats) based off the Presidents, since total there is every 26 letters from all the presidents used ... after a few guesses, maybe there are only 3 letters left. Then I guess from the letters available through the remaining president's names only. Hopefully that would help improve the guess filter.
I've chosen an MIT License. Do what you'd like with this material.
No images yet
You can email me at codefolio.work@gmail.com