Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

how do I put the quote in the required format..

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

// My Array of quote objects
var quotes = [
      { quote: 'To be prepared for war is one of the most effectual means of preserving peace.',
        source: 'George Washington',
        citation: 'Presidential Quotes',
        year: 1790,
        tags: 'Politics'
      },
      { quote: 'Men may die, but the fabrics of our free institutions remain unshaken.',
        source: 'Chester Alan Arthur ',
        citation: 'Presidential Quotes',
        year: 1881,
        tags: 'Politics'
      },
      { quote: "Mama always said life was like a box of chocolates. You never know what you're gonna  get inside.",
        source: 'Tom Hanks ',
        citation: "AFI's 100 Years...100 Movie Quotes",
        year: 1994,
        tags: 'Movies'
      },
      { quote: "If it doesn't fit, you must acquit.",
        source: 'Johnnie Cochran ',
        citation: "USA Today - 25 Most Memorable Quotes",
        year: 1995,
        tags: 'Judiciary'
      },
      { quote: "Until they become conscious, they will never rebel.",
        source: ' George Orwell ',
        citation: "www.goodreads.com",
        year: 1984,
        tags: 'Freedom'
      },
      { quote: "Stability and peace in our land will not come from the barrel of a gun, because peace without justice is an impossibility.",
        source: ' Archbishop Desmond Tutu ',
        citation: "Time Magazine",
        year: 1989,
        tags: 'Freedom'
      },
      { quote: "We are already old, it doesn't matter to us any more.",
        source: ' General Secretary Zhao Ziyang ',
        citation: "Time Magazine",
        year: 1989,
        tags: 'Democracy'
      }
];

//This function selects a random Quote object from the 'quotes' array
function getRandomQuote ( ) {
        var randomNumber = Math.floor ( Math.random() *  quotes.length )  ;
        var quote = quotes[randomNumber];
        return quote ;
}
//This function calls the getRandomQuote function and stores the return quote object in a variable
function printQuote ( ) {
        var getQuote = getRandomQuote ( ) ;
      document.getElementById('quote').innerHTML = getQuote.quote;
      document.getElementById('source').innerHTML = getQuote.source;
         }

printQuote( );

this is the format ....: <p class="quote"> [quote here] </p> <p class="source"> [source here] <span class="citation"> [citation here] </span> <span class="year"> [year here] </span> </p>

1 Answer

Hello Wade.

Please have a quick read here: https://teamtreehouse.com/forum/posting-code-to-the-forum

;) Vitto

Thanks for the heads up..