diff --git a/data/data.json b/data/data.json index 1c079e6..1e94bd2 100644 --- a/data/data.json +++ b/data/data.json @@ -1,62 +1,92 @@ [ { "quote": "The greatest glory in living lies not in never falling, but in rising every time we fall.", - "author": "Nelson Mandela" + "author": "Nelson Mandela", + "isAlive": false, + "age": 95 }, { "quote": "The way to get started is to quit talking and begin doing.", - "author": "Walt Disney" + "author": "Walt Disney", + "isAlive": false, + "age": 65 }, { "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" + "author": "Steve Jobs", + "isAlive": false, + "age": 56 }, { "quote": "If you set your goals ridiculously high and it's a failure, you will fail above everyone else's success.", - "author": "James Cameron" + "author": "James Cameron", + "isAlive": true, + "age": 68 }, { "quote": "Life is what happens when you're busy making other plans.", - "author": "John Lennon" + "author": "John Lennon", + "isAlive": false, + "age": 40 }, { "quote": "Tell me and I forget. Teach me and I remember. Involve me and I learn.", - "author": "Benjamin Franklin" + "author": "Benjamin Franklin", + "isAlive": false, + "age": 84 }, { "quote": "It is during our darkest moments that we must focus to see the light.", - "author": "Aristotle" + "author": "Aristotle", + "isAlive": false, + "age": 61 }, { "quote": "Whoever is happy will make others happy too.", - "author": "Anne Frank" + "author": "Anne Frank", + "isAlive": false, + "age": 15 }, { "quote": "Do not go where the path may lead, go instead where there is no path and leave a trail.", - "author": "Ralph Waldo Emerson" + "author": "Ralph Waldo Emerson", + "isAlive": false, + "age": 78 }, { "quote": "Life is really simple, but we insist on making it complicated.", - "author": "Confucius" + "author": "Confucius", + "isAlive": false, + "age": 71 }, { "quote": "Imagination is more important than knowledge.", - "author": "Albert Einstein" + "author": "Albert Einstein", + "isAlive": false, + "age": 76 }, { "quote": "Hold fast to dreams, for if dreams die, life is a broken winged bird that cannot fly.", - "author": "Langston Hughes" + "author": "Langston Hughes", + "isAlive": false, + "age": 66 }, { "quote": "The future belongs to those who believe in the beauty of their dreams.", - "author": "Eleanor Roosevelt" + "author": "Eleanor Roosevelt", + "isAlive": false, + "age": 78 }, { "quote": "Go confidently in the direction of your dreams. Live the life you have imagined.", - "author": "Henry David Thoreau" + "author": "Henry David Thoreau", + "isAlive": false, + "age": 44 }, { "quote": "You cannot depend on your eyes when your imagination is out of focus.", - "author": "Mark Twain" + "author": "Mark Twain", + "isAlive": false, + "age": 74 } ] diff --git a/examples/index.js b/examples/index.js index f924644..bd252ef 100644 --- a/examples/index.js +++ b/examples/index.js @@ -1,15 +1,23 @@ import getQuote, { getRandomQuote, getQuoteArrayLength, getQuoteByIndex } from "../lib/index.js"; const { quote, author } = getQuote(); +const randomQuote = getRandomQuote(); +const totalQuoteCount = getQuoteArrayLength(); const { quote: quoteWithoutAuthor } = getQuote({ author: false }); -const { quote: quoteByIndex, author: authorByIndex } = getQuoteByIndex(10); +const { quote: quoteByIndex, author: authorByIndex, isAlive, age } = getQuoteByIndex(10); console.log(`Here's a quote by "${author}": "${quote}"\n`); -console.log(`This is a random quote "${getRandomQuote()}"\n`); +console.log(`This is a random quote "${randomQuote}"\n`); console.log(`Here is the quote object without the author "${quoteWithoutAuthor}"\n`); -console.log(`How many quotes are there? -> ${getQuoteArrayLength()}\n`); +console.log(`How many quotes are there? -> ${totalQuoteCount}\n`); -console.log(`"${quoteByIndex}" \nby "${authorByIndex}"\nThis is the one I want.`); +console.log(`"${quoteByIndex}" \nby "${authorByIndex}"\nThis is the one I want.\n`); + +if (isAlive) { + console.log(`${authorByIndex} is alive and well`); +} else { + console.log(`${authorByIndex} was ${age} years old. He has passed away.`); +}