[Solved] Poem (random words) generator: How can I get each paragraph to display a different set of random words? [closed]


Right now you generate any word type just once.
Just generate the randoms before any phase

function makeAPoem() {
  var nouns = ["cat", "crow", "snow", "home", "boy", "raven", "tree", "moon", "night", "day", "winter", "heart", "angel", "madam", "darkness", "chamber", "lady", "bird", "person", "eye", "darkness", "air"];
  var verbs = ["ran", "felt", "fell", "focused", "looked", "stared", "sat", "sighed", "blew", "whimpered", "embraced", "hugged"];
  var articles = ["a", "the"];
  var adjectives = ["shiny", "sad", "cold", "cheerfully", "sweet", "evil"];
  var pronouns = ["I", "we", "you", "they", "she", "it", "he"];

  function randNoun(){return nouns[Math.floor(Math.random() * nouns.length)]}
  function randVerb(){return verbs[Math.floor(Math.random() * verbs.length)]}
  function randArticle(){return articles[Math.floor(Math.random() * articles.length)]}
  function randAdjective(){return adjectives[Math.floor(Math.random() * adjectives.length)]}
  function randPronoun(){return pronouns[Math.floor(Math.random() * pronouns.length)]}

  var phrase1 = randPronoun() + " " + randVerb() + " " + randAdjective();
  var phrase2 = randArticle() + " " + randNoun() + " " + randVerb() + " " + randAdjective();
  var phrase3 = randPronoun() + " " + randVerb() + ". " + randArticle() + " " + randNoun() + " " +  randVerb() + " " + randAdjective();
  var phrase4 = randArticle() + " " + randNoun() + " " + randVerb() + " " + randAdjective();
  var phrase5 = randPronoun() + " " + randVerb();

  document.getElementsByClassName('poem')[0].innerHTML = phrase1;
  document.getElementsByClassName('poem')[1].innerHTML = phrase2;
  document.getElementsByClassName('poem')[2].innerHTML = phrase3;
  document.getElementsByClassName('poem')[3].innerHTML = phrase4;
  document.getElementsByClassName('poem')[4].innerHTML = phrase5;
}
<div id="poemBox">
<div id="edgar">
  <img src="https://cdn.britannica.com/52/76652-050-F4A6B093/Edgar-Allan-Poe.jpg" width="150px" alt="avatar">
  <p>Press the button below for a poem from Poe.</p>
  <button onclick="makeAPoem()">Go</button>
</div>
<div id="poetry">
  <p class="poem"></p>
  <p class="poem"></p>
  <p class="poem"></p>
  <p class="poem"></p>
  <p class="poem"></p>
</div>

solved Poem (random words) generator: How can I get each paragraph to display a different set of random words? [closed]