Hi Guys! Just finished the random quote generator. Didn’t understand how to request data from the Forismatic server/API. So I did some research and turned to Stephen Mayeux’s video tutorial to further break it down for me. It was awesome!!! Will improve the generator but please give me some feedback. Check it out here Thnx!
Do not use
<br>
to increase the gap between lines of text; use the CSS margin property or the<p>
element. (<br>: The Line Break element - HTML: HyperText Markup Language | MDN)
I’m not sure this is a correct syntax:
font-family: "san serif, courier";
Try not to use id
s in CSS. Add classes to your HTML and style them. Leave id
s for JavaScript and links.
It’s a good practice to add error
handler in AJAX calls, so if there is some error while fetching data your code doesn’t crash and user gets informed.
You could also save some typing:
if (author) {
$("#author").html("~" + author);
} else {
$("#author").html("~ Unknown");
}
could be replaced with:
$("#author").html("~" + (author || ' Unknown'));
or even:
$("#author").html(`~${author || ' Unknown'}`);
If you remove href="#"
from links, you can get rid of e.preventDefault()
;
1 Like
Thank you so much!!! This is quite helpful