javascripthtmlcssgithub pages

Wits and Wisdom

By Kendall Johnson
Picture of the author
Published on
Application Type
JavaScript Browser Game
Landing Page
Landing Page
Technology Trivia Screen
Technology Trivia Screen
Loss Logic Screen
Loss Logic Screen
Win Logic Screen
Win Logic Screen

Wits and Wisdom is an engaging trivia game that uses HTML, CSS, and JavaScript to deliver a dynamic and interactive experience. Through the implementation of DOM, Event Listeners, and several other key tools provided from the likes of JavaScript the user is fist given the option of which category they wish to select. Once a category is selected, at a pace of one question at a time, the user is given four choices of answers and they must decipher which is the correct one.


Code-Block

Although, it appears relatively short in nature, this block of code serves as the legs to this walking machine. It renders a random question based on the category selected and iterates through the beginning array of objects to grab not only that random question, but its accompanying answer choices. Without this block of code, almost nothing else functions. The harmony within all the separate gears turning here are like the melody of a song you cannot get out of your head.

  function nextQuestion() {
      if (!gameEnded) {
          const randomIdx = Math.floor(Math.random()* 10);
          randomQuestion = questions[randomIdx];
          const currentQuestion = randomQuestion.question;
          const choices = randomQuestion.choices;
          questionEl.innerHTML = currentQuestion;
          for (let i = 0; i < choices.length; i++) { 
              const choiceEl = choicesEls[i];
              choiceEl.innerHTML = choices[i];
          }
      }  
  }  

The reviews are rolling in...

Great job, Kendall! The attention to detail with the CSS and consideration of user experience is above and beyond.

  • Payne Fulcher, General Assembly

The CSS is incredible man, and I like the question variety. Really nicely done

  • Vilem McKael, General Assembly

Love it! This is great Kendall 👍

  • Collin Barlow, General Assembly

Roadmap

I have a few key changes I hope to implement in the near future to increase the functionality of the game. They are as follows:

  • Add a wider question base
  • Implement a more reactive environment to different screen and display sizes
  • Streamline the current code using React and other JavaScript Libraries

Get in touch

Let's discuss how I can be a strong addition to your team!

Your contact information
Add a message: