Map vs JSON Random Quote Machine

I’m building my random quote machine and I don’t wanna use an API now.

So, I was gonna use a map to storage quote’s texts and authors, but then I thought I could create a JSON for this. Can I?

If I can, what are the pros and cons of each approach? And can I just save the json file in a json folder, like images or css?

A map seems like overkill. Why not just an array of strings? Yes, you could store it in a separate json file, but then that might get a little tricky in codepen.

1 Like

I agree with @ksjazzguitar, in my opinion the simples possible solution would be to create an array of strings, and then get one of that randomly to display on the screen.

If later on you decide to move from an array to an API you can keep the function, but change the location where to pick up the string from the array to an external API.

1 Like