This simple, web based trivia game was created through the digestion of API data through a JavaScript function. The game is intended to be played with a mobile web client, as a user can swipe left or right to cast their vote. The game not only keeps track of the current question, but tracks how much questions a user got right in real time.  How the game functions is through the use of arrays. The questions ingested from the Open Trivia DB can be selected much like data contained within an array. To utilize this, a hidden JavaScript variable is used to reflect the current question a user is on.  When a user casts their vote, the value of this variable increases which swaps the answered question with the next one.  If the user answered correctly, a 1 is stored into a separate array while a zero is stored if their answer was incorrect. This allows for a simple calculation to be made with each vote. 
You can try it out with the link below.

You may also like

Back to Top