Git Product home page Git Product logo

random-quote-generator's Introduction

random-quote-generator

Treehouse Techdegree Project #1 - Random Quote Generator

Project Requirements

Create an array of JS objects to hold the data for the quotes.

Each quote should have the following properties:

  • A quote property which contains a string: the text of the quote to display on the page.
  • A source property which contains a string identifying the creator of the quote.
  • An optional citation property which contains a string identifying the publication the quote appears in.
  • An optional year property which contains a number identifying the date of the quote.

Create a function named getRandomQuote which:

  • selects a random quote object from the quotes array
  • returns the randomly selected quote objects

Create a function named printQuote which follows these rules:

  • printQuote calls the getRandomQuote function and stores the returned quote object in a variable.
  • printQuote constructs a string using the different properties of the quote object using the following HTML template:
<p class="quote"> [quote here] </p>
<p class="source"> [source here]
  <span class="citation"> [citation here] </span>
  <span class="year"> [year here] </span>
</p>
  • printQuote doesn't add a <span class="citation"> for a missing citation or a <span class="year"> if the year property is missing.
  • printQuote displays the final HTML string to the page. You can use the following JS snippet to accomplish that: document.getElementById('quote-box').innerHTML

Extra Credit

  • Add more properties to the quote object. For example, a tags property could include a list of "tags" like -- "humor", "business", "politics" -- to categorize each quote.
  • Randomly change the background color of the page, when the quote changes
  • Don't display a random quote more than once until ALL quotes from the array have been displayed.
  • Refresh the quote after a set amount of time. For example, every 30 seconds, make a new quote appear. (You can use the setInterval() or setTimeout() method to do this -- see the links in the Project Resources listing.)

View Project

Live Demo of this project for peer review.

random-quote-generator's People

Contributors

b2point0h avatar

Stargazers

 avatar Bastián González-Bustamante avatar Muhammad Umar avatar a tech geek avatar Mkenas avatar Javier Guerra avatar Tonye Fiberesima avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.