Random quote machine - How random should my random machine be?

Hi! So I didn’t see a similar question in my search, I’m on the planning stage for my quote machine project and here’s what I was thinking on doing:

The core, without getting into the “sharing” part, should be getting information from a JSON file and use a function with a math.random to select which node of the json object should be loaded. Loading a new quote should be something similar, calling the function that selects a new “index” from my json object.

Here’s my problem with that approach, though, it’s very likely that my “new” random quote is the same than the one before, given the way that random numbers are generated (in my time it had to do with the processor’s temperature or something like that).

What I was thinking of is, yeah, ask for the JSON object, but instead of asking a random index from it, make a list with the contents of the object in a random order. I did a program in java once, that “shuffled” a deck of cards, so I think it would be a simple version of that. This way, the order of the list of quotes is still random and there’s no way you’ll get the same quote unless you go through all the list.

I bounced the idea with a developer and he told me that this was actually what it’s usually done to prevent the “repetition” problem. So, here’s my question.

Does FCC enforce solving the random quote challenge with the first method I described (random every single time) or am I allowed to solve with the second method? Would it be weird? Would it be a problem if I asked for the certification and my solution was unexpected? Toughs? : D

I just don’t want to start coding and realize I totally misunderstood the challenge. Thanks!

1 Like

The user stories are very general and there is no requirement as to the method you use to get your quote. You can build a list, use a random integer, fetch from a remote API, use any combination of these or even something completely different. As long as you understand the code you’ve written, can talk about it, and it’s publicly hosted, you should be good to go. If you desire more structure, there are automated test suites for each project. Fork the Codepen here. See this thread for more info.

2 Likes

Thank you both for your advice! Will start coding then.

1 Like