JSFiddle - React, Tailwind, and code Playground

HTML

<div class="container">
  <div id="quote-box">
    <p class="quote">You can do anything but not everything</p>
    <p class="source">David Allen<span class="citation">Making It All Work</span><span class="year">2009</span></p>
  </div>
  <button id="loadQuote">Show another quote</button>
</div>

JavaScript

// event listener to respond to clicks on the page
// when user clicks anywhere on the page, the "makeQuote" function is called
document.getElementById('loadQuote').addEventListener("click", printQuote, false);

// variable that will hold viewed quotes
var viewedQuotes = [];

// get random quote function that selects a random quote object from the quotes array
// and returns the randomly selected quote object
function getRandomQuote() {
  var theQuote = Math.floor(Math.random() * quotes.length);
  var splicedQuote = quotes.splice(theQuote, 1)[0];
  viewedQuotes.push(splicedQuote);
  if (quotes.length == 0) {
    quotes = viewedQuotes;
    viewedQuotes = [];
  }
  return splicedQuote; // changed "quotes[theQuote]" to "splicedQuote"
}

// printQuote calls the getRandomQuote function and stores the returned quote object in a variable
// printQuote constructs a string using the different properties of the quote object using the following
// HTML template: <p class="quote"> [quote here] </p> <p class="source"> [source here]
// <span class="citation"> [citation here] </span> <span class="year"> [year here] </span> </p>
// printQuote doesn't add a <span class="citation"> for a missing citation or a
// <span class="year"> if the year property is missing
// printQuote displays the final HTML string to the page. You can use the following
// JS snippet to accomplish that: document.getElementById('quote-box').innerHTML
function printQuote() {
  var selectedRandomQuote = getRandomQuote();
  var html = '<p class="quote">' + selectedRandomQuote.quote + '</p>' + '<p class="source">' + selectedRandomQuote.source +
    '<span class="citation">' + selectedRandomQuote.citation + '</span>' + '<span class="year">' + selectedRandomQuote.year + '</span>' + '<span class="category">' + selectedRandomQuote.category + '</span>' + '</p>';
  document.getElementById('quote-box').innerHTML = html;
}


var quotes = [{
  quote: 'The journey of a thousand miles begins with one step.',
  source:...