commit b34d74414be440dc6043e61117654b4d8a39b6c7 Author: Jonathan Branan Date: Sun Sep 1 21:53:57 2024 -0500 created random quote generator diff --git a/c.html b/c.html new file mode 100644 index 0000000..e311a8d --- /dev/null +++ b/c.html @@ -0,0 +1,14 @@ + + + + + + Random Quote Generator + + +

Random Quote Generator

+

+ + + + \ No newline at end of file diff --git a/c.js b/c.js new file mode 100644 index 0000000..58a8944 --- /dev/null +++ b/c.js @@ -0,0 +1,35 @@ +const quotes = [ + "The greatest glory in living lies not in never falling, but in rising every time we fall. -Nelson Mandela", + "The way to get started is to quit talking and begin doing. -Walt Disney", + "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. -Steve Jobs", + "The future belongs to those who believe in the beauty of their dreams. -Eleanor Roosevelt", + "If you look at what you have in life, you'll always have more. If you look at what you don't have in life, you'll never have enough. -Oprah Winfrey", + "If you set your goals ridiculously high and it's a failure, you will fail above everyone else's success. -James Cameron", + "You may say I'm a dreamer, but I'm not the only one. I hope someday you'll join us. And the world will live as one. -John Lennon", + "You must be the change you wish to see in the world. -Mahatma Gandhi", + "Spread love everywhere you go. Let no one ever come to you without leaving happier. -Mother Teresa", + "The only thing we have to fear is fear itself. -Franklin D. Roosevelt", + "Darkness cannot drive out darkness: only light can do that. Hate cannot drive out hate: only love can do that. -Martin Luther King Jr.", + "Do one thing every day that scares you. -Eleanor Roosevelt", + "Well done is better than well said. -Benjamin Franklin", + "The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart. -Helen Keller", + "It is during our darkest moments that we must focus to see the light. -Aristotle", + "Do not go where the path may lead, go instead where there is no path and leave a trail. -Ralph Waldo Emerson", + "Be yourself; everyone else is already taken. -Oscar Wilde" +] + +const usedIndexes = new Set() +const quoteElement = document.getElementById("quote") + +function generateQuote(){ + while (true){ + const randomIdx = Math.floor(Math.random() * quotes.length) + if(usedIndexes.size === quotes.length) usedIndexes.clear() + if(usedIndexes.has(randomIdx)) continue + + const quote = quotes[randomIdx] + quoteElement.innerHTML = quote + usedIndexes.add(randomIdx) + break + } +} \ No newline at end of file