Flag Trivia Game
A simple flag trivia game where 1 or multiple players can test themselves to see how many country flags they know. A custom amount of turns can be set (between 3 to 100). The game was created using HTML, CSS, and JavaScript.
Simply download the Zip folder for the repo, or fork it, and open up the index.html file on your computer.
The game was created by using the REST countries API in order to create an array of objects, each object containing a name and flag url. This was then passed into functions which selected out a random country to be set as the “correct ansewer” and an addition 3 random countries to be passed in as choices, fisher-yates was used as the shuffle method. The flags are background images to their respective button elements within the HTML document, a function titled setFlags()
was used to interact with the DOM. Upon the users click, an event is logged which keeps track if score should be added, the passing of a turn, and the clearing of the board, proceeding to a loop of the function which sets the random countries again pickRandomCountries()
. Additionally, the “Custom Game” button in the top left corner of the screen allows for the player to add additional players (for group games), and/or set the number of turns in a game round (between 3 turns to 100).
The game logic is sound but does contain a few bugs I would like to clean up eventuallay, those being:
countryChoices
array has been started but as of yet still needs to be fixed.alert()
for wrong picks, replaced with either a big red X over the chosen button element OR idealy, a modal which displays the correct flag the user should have choosen. This popup could even be an option feature the user could turn on/off within the “Custom Game” button.