Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


  <div id="quote-box">
    <p class = "quotes"><i class="fa fa-quote-left" aria-hidden="true"></i>'What happened?'</p>
    <p class = "quotes"><i class="fa fa-quote-left" aria-hidden="true"></i>Test2</p>
    <p class = "quotes"><i class="fa fa-quote-left" aria-hidden="true"></i>Test3</p>
    <p class = "quotes"><i class="fa fa-quote-left" aria-hidden="true"></i>Test4</p>
    <p class = "quotes"><i class="fa fa-quote-left" aria-hidden="true"></i>Test5Test</p>
    <button id="generate">New Quote</button>
    <button id="btnTweet"><i class="fa fa-twitter" aria-hidden="true"></i></button>
  <footer> by joshua</footer>


                h1 {
  text-align: center;
  padding: 30px;

body {
  background: brown;
  text-align: center;

#quote-box {
  border-radius: 5px;
  height: 300px;
  width: 30%;
  text-align: center;
  margin: auto;
  background: white;

footer {
  color: white;
  margin-top: 2px;
  font-size: 12px;



var quotes = document.getElementsByClassName("quotes");

document.addEventListener("DOMContentLoaded", function(){
  // Handler when the DOM is fully loaded
  for (var i = 0; i <= quotes.length; i++) {
    quotes[i].style.display = "none";
  //On line 5 + 6 we have 'for' loop that iterates through 'quotes' array we created when selecting getElementsByClassName. It sets each of the elements with the class 'quotes' to 'display = none'.

  //Beloew we have VanillaJS click event.
  document.getElementById("generate").addEventListener("click", function (event) {
      //Below we have a random number generator assigned to the var 'random'.
      var random = Math.floor(Math.random() * quotes.length);
    //Another for loop that iterates over the quotes array.
      for (var i = 0; i < quotes.length; i++) {
        //Need to update explanation of this code once I receive a respone from SO.
        quotes[i].style.display = (i==random) ? "block" : "none"; 
        curQuote = quotes[random].innerText;
 document.getElementById("btnTweet").addEventListener("click", function (event) {
    var textToTweet = curQuote;
    var twtLink = ',fcc&related=freecodecamp&text=' +encodeURIComponent(textToTweet);,'_blank');