Random Quote Generator...I have to ask!

I have no idea how to build this random quote generator and I could try until the day I die and i would still not be able to create this random quote generator without at least looking at the code. I don’t even know where to start. I have copied and pasted code into the cat app but I don’t see how that quite prepares me for this. I went to the site where the random quote api is and I couldn’t find anything there that even mentioned javascript, I could get it in plenty of other codes but no javascript. I know that the acronym json is javascript something something (I can’t be bothered Googling it) but don’t see the resemblence to javascript. I’m having another one of these anger attacks where I feel I’m being made a fool of but I’m trying really hard not to be a knob about it this time. Can someone please help me as Read Search Ask is a complete waste of time.

Well I have clearly and certainly faced those attacks while dealing with json and particularly with ajax …
you know the primary purpose of creating javascript was to be able to manuplate DOM the way you want … i.e the website the way you want …
what json is that its a way to store the data **Javascript Object Notation ** and send it to the user when it requires ( in our case the data is a quote ) .
(the name Json being because a javascript object can be converted to a json

myObj = { "name":"John", "age":31, "city":"New York" };

`
above here is an object myObj that has various properties ( name , age ) and their respective values ``
what javascript does is that it takes that data and parses it so that we can understand what it contains then with the help of javascript we append the data in the web browser ( in real time ) which is called ajax .
_The important thing if you wanna read is down here : _
The need for this is because data sent over websites cannot be javascript objects but simple plain texts … so we encode it like a text for some time … then change it back to javascript objects so that we can use it again on the other side!
json=>“very simple way to store javascript objects” simple terms
ajax=>“appending in real time” in very simple terms

also I am no expert so I may not be able to clear things up …
Cheers!

1 Like

You don’t need an API for this, and I strongly advise against trying to use one.

Read-Search-Ask is what you’d be spending most of your development time doing in a work environment. Typing code doesn’t take much time, and you’ll always be expected to learn new things. You have to be comfortable feeling lost or you’re going to hate programming. I’m not saying it isn’t OK to be frustrated sometimes, it’s a natural reaction and the reason why we have the forums and the chat. Just keep in mind that this isn’t a waste.

To start this project, think about what you’ll need to do:

  • Store quotes in a way that you can access them randomly
  • Randomly select a new quote when the user presses a button
  • Display the randomly selected quote on your page
  • Send the currently displayed quote out on Twitter when the user clicks a button

Here are some resources to help:

Random Numbers

Gnerate Random Whole Numbers with JavaScript
Generate Random Whole Numbers within a Range
Array.length

Storage

Here’s a useful data structure

Handle User Clicks

Trigger Click Events with jQuery

Display Text On Page

Change Text with Click Events
.html()

When it is time for you to learn about AJAX, try outside sources. There are a lot of tutorials on YouTube:

AJAX videos
Let’s learn AJAX - I made this pen as an interactive example for people to get their hands dirty with some simple, promise-based AJAX. I don’t claim that it’s good or that you’ll learn what you need just from this pen alone, but after you’ve watched a video or two, give it a try. It may help solidify some concepts.

2 Likes

Hi Dsxv, Thank you for your understanding of my frustration and also, for you very well written response. I guess my anger stems from my own feelings of inadequacy, stemming from my not finishing high school and knowing that on a lot of levels I’m dumber than the average Joe. Your explanation actually clears quite a lot of stuff up for me and gives me an idea of the point behind json and ajax, which before reading your reply, I had no clue. I will have to do a bit more digging to try to figure out the Random Quote Generator problem but I will be searching for the answers I seek with a bit more knowledge under my belt. Cheers to you too.

1 Like

Thank you for your reply PortableStick, I know that frustration is going to be something I have to get more comfortable with if I am to continue down the coding path. I love coding and enjoy, for the most part, every second of it, but every so often I get what I can only describe as an overwhelming feeling of complete confusion where by I feel my brain just doesn’t have the capacity for learning this stuff. I am fine when there is an example to look at but when I’m staring at a blank screen I have no clue where to start. I will check out the links you gave me and take it from there. I am extremely impressed by the support that I have found on freecodecamp and profoundly apologise for my comment about Read-Search-Ask being a waste of time, as it is anything but.