<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
     <link
  rel="stylesheet"
 href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"
/>
  </head>

  <body>
<div id="wrapper">
  <div id="quote-box">
    <div class="quote-text">
      <i class="fa fa-quote-left" style="margin-right:7px;"></i><span id="text"></span>
    </div>
    <div class="quote-author">- <span id="author"></span></div>
    
      <a href="#" id="tweet-quote" target="_blank" class="btn btn-block btn-primary"></a>
     
      <button class="button" id="new-quote" onClick="generateQuote();" style=color:black;text-align:center;background-color:white;border-radius:6px;padding:8px18px6px18px;margin-top:10px;opacity:1;cursor:pointer;">New quote</button>
    </div>
  </div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js"></script>
  </body>
@import url('https://fonts.googleapis.com/css2?family=Cinzel&family=Square+Peg&display=swap');

button{
  width: 100px;
margin-left: 10px;
}

.quote-text {
  padding: 10px;
    text-align: center;
    width: 450px;
    height: auto;
    clear: both;
    font-weight: 500;
    font-size: 20px;
  }
.quote-author {
    width: 450px;
    height: auto;
    clear: both;
    padding-top: 20px;
    font-size: 15px;
    text-align: right;
  }
body {
  background-color: black;
  color: black;
  font-family: 'Cinzel', serif;
  font-size: 20px;
  font-weight: 400;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}
#quote-box {
  border-radius: 8px;
  position: relative;
  //margin:8% auto auto auto;
  width: 450px;
  padding: 40px 50px;
  display: table;
  background-color: white;
}
  
  
  


       const QUOTEBANK = [
         {
          quote: "Darkness cannot drive out darkness, only light can do that. Hate cannot drive out hate, only love can do that.",
        author: "Martin Luther King Jr."
            },
            {
        quote: "Don't use your brain to play it, let your feelings guide your fingers.",
        author: "Jimi Hendrix"
            },
            {
        quote: "All your life, you will be faced with a choice. You can choose love or hate…I choose love.",
        author: "Johnny Cash"
            },
            {
           quote: "The greatest glory in living lies not in never falling, but in rising every time we fall.",
        author: "Nelson Mandela"
            },
         {
           quote: "The way to get started is to quit talking and begin doing.",
        author: "Walt Disney"
            },
         {
           quote: "Your time is limited, so don't waste it living someone else's life. Don't be trapped by dogma – which is living with the results of other people's thinking.",
        author: "Steve Jobs"
            },
         {
           quote: "If life were predictable it would cease to be life, and be without flavor.",
        author: "Eleanor Roosevelt"
            },
         {
           quote: "If you look at what you have in life, you'll always have more. If you look at what you don't have in life, you'll never have enough.",
        author: "Oprah Winfrey"
            },
         {
           quote: "If you set your goals ridiculously high and it's a failure, you will fail above everyone else's success. ",
        author: "James Cameron"
            },
         {
           quote: "Life is what happens when you're busy making other plans.",
        author: "John Lennon"
            },
         {
           quote: "When you reach the end of your rope, tie a knot in it and hang on.",
        author: "Franklin D. Roosevelt"
            },
            {
           quote: "Always remember that you are absolutely unique. Just like everyone else.",
        author: "Margaret Mead"
            },
         {
           quote: "Don't judge each day by the harvest you reap but by the seeds that you plant.",
        author: "Robert Louis Stevenson"
            },
         {
           quote: "Tell me and I forget. Teach me and I remember. Involve me and I learn.",
        author: "Benjamin Franklin"
            },
         {
           quote: "It is during our darkest moments that we must focus to see the light.",
        author: "Aristotle"
            },
         {
           quote: "Whoever is happy will make others happy too. ",
        author: "Anne Frank"
            },
         {
           quote: "The best and most beautiful things in the world cannot be seen or even touched — they must be felt with the heart.",
        author: "Helen Keller"
            },
         {
           quote: "Do not go where the path may lead, go instead where there is no path and leave a trail.",
        author: "Ralph Waldo Emerson"
            },
         {
           quote: "In the end, it's not the years in your life that count. It's the life in your years.",
        author: "Abraham Lincoln"
            },
         {
           quote: "Never let the fear of striking out keep you from playing the game.",
        author: "Babe Ruth"
            },
    ];

      window.onload = init;
      function init() {
        generateQuote()
      }

      function generateQuote() {
        let quoteSize = QUOTEBANK.length;
        let randomIndex = Math.floor(Math.random() * quoteSize);
        let randomQuoteData = QUOTEBANK[randomIndex];

        let twitterLink = "https://twitter.com/intent/tweet?hashtags=quotes&amp;related=freecodecamp&amp;text="

        // Add The Quote
        let quoteInApiFormat = randomQuoteData.quote.replace(/ /g, "%20");
        twitterLink += quoteInApiFormat
        // Add the Author
        let authorInApiFormat = randomQuoteData.author.replace(/ /g, "%20");
        twitterLink += " - " + authorInApiFormat

        document.getElementById("tweet-quote").href = twitterLink;
        document.getElementById("text").innerText = randomQuoteData.quote;
        document.getElementById("author").innerText = randomQuoteData.author;
      }
 
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.