Feedback on Drew's random quote generator

Feedback on Drew's random quote generator
0.0 0

#1

I made a pretty basic random quote generator and have it here at code pen https://codepen.io/dmoneyballer/full/XEaOJZ/

What can I do better with it? I tried to use vanilla javascript but used jquery because I couldn’t get the api to load because the page status never got to 4 which appeared to be the loaded status… any feed back on how to use vanilla javascript to make the call to the api library would be appreciated.

I made the quote library and can modify it but I was wondering how I can place a dash (-) before the author’s name? Do I have to modify my quote library to have an - before the author’s name or can I use a

tag to insert it where I’m targeting my API insert

Another question I have is how important is html tidying? I input the html to a site and it gave me like 200+ errors. the site runs in codepen and when i run it from Atom where I typed it up. How concerned should I be about this?

Sorry if I have too many questions any constructinve feedback will be appreciated.


#2

I input the html to a site and it gave me like 200+ errors. the site runs in codepen and when i run it from Atom where I typed it up. How concerned should I be about this?

The code between <script> and </script> is javascript, not html^^ I think that’s the source of those 200+ ‘errors’ :stuck_out_tongue:
About codepen you might cut/paste your javascript code inside the js section without the <script> tag, everything is linked behind the scene^^

any feed back on how to use vanilla javascript to make the call to the api library would be appreciated.

I won’t share any code, not because i do not want to help, but simply because you’ve already found the solution! You just have to use the url as fetch parameter ( Using fetch - MDN docs ) and the quotes will appear in your console log^^

I made the quote library and can modify it but I was wondering how I can place a dash (-) before the author’s name? Do I have to modify my quote library to have an - before the author’s name or can I use a

tag to insert it where I’m targeting my API insert

You can concatenate string as follows with the plus sign: $("#author").html( '-' + data[quoteId].author);

You can use template literals too: $("#author").html(` - $(data[quoteId].author)`); ( Template literals - MDN Docs )


#3

Thank you so much for answering all my questions. I really appreciate it. :slight_smile: