Hey guys, hope you are having a good time .
Would you please try my project and give me some feedbacks, the project basically gave us instructions to create a javascript quote generator but since this project wasn’t that hard i extend it to html css and some jquery .
hope i did some good job .
Thank you very much sir for your review, the thing is i was a little lazy to search for some quotes … but after googling i found a big list of quote, author object so i said with myself why not using it and save some time since i was a little in hurry .
Thank you for the article it was very informative.
Nice work adding the webpage to have an interface for the project. Taking projects to the next level is a great learning experience.
As for some feedback, I’d suggest separating out the function responsibilities a bit more in future projects. For example, the bulk of your program is inside a function named getRandomColor(), including the array of 1643 quote objects, and it returns an array with the color, author, and quote. Then there is setRandomColor() which is setting the color but also populating the quote details in the webpage. This is working right now, but it’s something to be conscious of as you work on larger projects or with a team.
There is a small issue here:
function setRandomColor() {
$("body").css("background-color", getRandomColor()[0]);
$(".qcontainer").html(`"${getRandomColor()[1]}"`);
$(".author").html(`'${getRandomColor()[2]}'`);
}
Since you’re calling getRandomColor() each time you access a different element of the array ([0] for color, [1] for quote, [2] for author), it’s returning a different random array each time. This would mean that the quote wouldn’t match the author most of the time.
What you could do here is call getRandomColor() once and save the results to a variable, then use that variable with [0], [1], [2] like you’re doing now to get each of the elements. Since getRandomColor() is only called once, the quote and author are definitely matched up.
I really like that you’ve created an interface for the project and the quote database you found.
Overall, you did a good job. I’m looking forward to seeing your next project.
Thank you very much for the review , i didn’t fully understand your description until i did some debugging .
I was able to fix the bug by separating the functions and give better names lol . now the code is working properly after i checked it out some times.
Thank you very much i appreciate the help.