Random quote help needed

HTML

<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>

<div class="container">
  <br /> <br />
  <div class="row">
    <div class="col-4">
      <h1>Random Quotes</h1>
      <h3>By Ellis</h3>
    </div>
    <div class="col-8">     
      <div id="quote-box">
        <div class="row">
          <div class="col-12">
            <div id="text">
              
            </div>
          </div>
          <div class="col-4">
            <div id="author">
                
            </div>
          </div>
          <div class="col-6">
            <a id="tweet-quote"><button> Tweet</button></a>
            <button id="new-quote" type="submit">New Quote</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>```


JS 

$(document).ready(function(){
function getQuote() {

let author = ["Kanye", "Kanye", "Holmer", "Ellis"];
let quotes = ["My music isn’t just music — it’s medicine.", "My greatest pain in life is that I will never be able to see myself perform live.", "Now I am become death, destroyer of worlds.", "Fair Enough"];

let Num = Math.floor((Math.random()*4));  
let currentQuote = quotes[Num];
let currentAuthor = author[Num];
$("#author").text(currentAuthor);
$("#text").text(currentQuote);
$("#new-quote").on("click", function() {
  getQuote();
});
console.log(quotes);

}
});



I have no idea what my issue is

Please elaborate on what is happening. What is the error? What’s wrong? This will make it easier for everyone to help.

It is very likely that your math.floor->math.random function will return same value many times as you have Math.random()*n where n=4 in your case. If you increase the n you will probably get more unique values.

Your issue that you’re declaring getQuote and never calling it, so you never really start to listen to click event. Try moving event listener out of function’s body

1 Like

thats the thing nothing is happening.
its not logging errors in my console.

I think maybe there is something wrong with my jQuery doc grab but idk what.

Nothing will happen in your app until this line will run:

As a little hint: that line isn’t running if console.log(quotes); doesn’t log anything
Read your code again and try to guess, why that line isn’t running

This is what it was!