Skip to content

Instantly share code, notes, and snippets.

Created May 17, 2018 22:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save waldothedeveloper/3a3c37dbc6aa23791e8b65a6039e27e0 to your computer and use it in GitHub Desktop.
FreeCodeCamp Random Quotes App
$(document).ready(() => {
$("i#tweet-icon").on("click", () => {
let quote = $.trim($("#quote").text());`${quote}`);
let endpoint = '';
let getRandomQuote = () => {
$.getJSON(`${endpoint}`, (data) => {
$("#quote").html(`<i class="fas fa-quote-left"></i> ${data.quoteText} <i class="fas fa-quote-right"></i>`);
//Checking if the quote does not have an author
if (data.quoteAuthor !== "") {
$("#quote-author").html(`${data.quoteAuthor} at <a href="${data.quoteLink}" target="_blank" class="card-link">forismatic</a>`);
} else {
$("#quote-author").html(`Unknown at: <a href="${data.quoteLink}" target="_blank" class="card-link">forismatic</a>`);
//Create a tweet function
function tweetQuote() {`${data.quoteText}`);
$("#tweet-icon").on("click", tweetQuote);
};//end of getRandomQuote
$("#quote-button").on("click", getRandomQuote);
});// end of document.ready
<!doctype html>
<html lang="en">
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
<!-- Font Awesome icons -->
<link rel="stylesheet" href="" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp"
<title>Random Quotes App</title>
body {
background-color: #333 !important;
<div class="container mt-5">
<div class="row">
<div class="card mt-5 mx-auto" style="width: 32rem; height: 23rem;">
<div class="card-header justify-content-between" style="display: flex;">
<small class="text-left">Random Quotes</small>
<i id="tweet-icon" class="text-right fab fa-twitter fa-lg"></i>
<div class="card-body">
<blockquote class="blockquote mb-0">
<p id="quote" style="height: 8rem;">
<i class="fas fa-quote-left"></i> Never apologize for showing feelings. When you do so, you apologize for the truth.
<i class="fas fa-quote-right"></i>
<footer id="quote-author" class="blockquote-footer mt-3">
Benjamin Disraeli
<div class="row"></div>
<a id="quote-button" href="#" class="mt-3 mb-3 btn btn-dark">Next</a>
<div class="card-footer bg-transparent border-dark">
<small>Thanks to
<a href=""></a> for their awesome quotes API
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
<script src="" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
<script src="" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
<!-- Local javascript -->
<script src="app.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment