Random quotes generator

Hello Friends, In this blog, we will work on a javascript project called random quotes generator. We will generate different quotes from famous people using simple HTML CSS and javascript codes. Many online services can help you to generate random quotes but I thought it’s better to learn how to generate random quotes yourself. It’s more fun to generate the quotes yourself. I hope you will enjoy this project. Before collecting the code I will suggest you watch the video tutorial below. This tutorial shows step by step process on how to create a random quotes generator in javascript. We have over 1000+ videos on our youtube channel about front-end-development. If you are interested to learn front-end you can subscribe to our YouTube Channel.





What is Random Quotes Generator? Random Quotes Generator is a very simple app. It is a web application that can be used to generate random quotes. In this Project, you can find a 'Find Quotes' Button which will generate different quotes with the writer's name when you click on it. Here we have an index.html file where we have designed the UI of the project and then we have a style.css file where we have styled the elements of the project. After that, we have a custom.js file where we have used vanilla javascript to make the quote generator. In the custom.js file, we will first take an array. In this array, we will put all the quotes as an object. We will name the array as quotes. First of all, we will create an object and then put property and value in it. We have included the quote and writer's name in the object. I have included ten quotes here but you can take as many quotes as you want. Please follow the above tutorial to understand what I am saying. After that, we have to select all the needed elements of the project and put them into separate variables. After that, we will include a click event to the button. As we are creating a random quote generator so all the quotes have to appear randomly not sequentially. So we have applied a method named 'random'. This Math.random method is used as we know for creating random numbers. So when we click on the button random numbers (quotes in this case) will appear on the box. If we check the code on the console we will get fractions of numbers. That's why we have to add quotes.length in our code. Later we have shown the quotes and writer names using a random method.

You May Also Like:


Random quotes generator in javascript [ Source Code ]:


To complete this project you will need to create a few different files. The first of these is an HTML file, the second is a CSS file and the third is a JavaScript file. Copy the code from the below code box and paste them into your project. You can download the code from the download button below.


ADD HTML




ADD CSS:




ADD JS:





I hope you have successfully implemented the code. Please share the articles on this blog. Learn for yourself and help others learn. Thanks for visiting our Blog.

Post a Comment

Please Do not Enter any spam link in the comment box