r/JavaScriptTips • • Sep 27 '22

JSON

Hello I need help, I have assignment to create quiz using JSON, here is data.json and I need to parse it to get quiz form like this, and after that i need to import local storage but that is not problem, problem is to parse it to create questions like this.

I don't have too much time to do this so can someone help me how to do this, thank you <3.

var json = '{"quiz": {"q1": {"question": "Which one is correct team name in NBA?","options": ["New York Bulls","Los Angeles Kings","Golden State Warriros","Huston Rocket"],"answer": "Huston Rocket"}, "q2": {"question": "Namaste is a traditional greeting in which Asian language?","options": ["Hindi","Mandarin","Nepalese","Thai"], "answer": "Hindi"},"q3": {"question": "The Spree river flows through which major European capital city?","options": ["Berlin","Paris","Rome","London"],"answer": "Berlin"},"q4": {"question": "Which famous artist had both a Rose Period and a Blue Period?","options": ["Pablo Picasso","Vincent van Gogh","Salvador Dalí","Edgar Degas"],"answer": "Pablo Picasso"}}}'

5 Upvotes

5 comments sorted by

4

u/TeslaRanger Sep 27 '22

So, you want us to do your homework for you?

Would you like our lunch money too?

2

u/gerbs650 Sep 28 '22

No bro just share your GitHub with the guy /s

-1

u/fare03 Sep 28 '22

No just tell me how to parse it and that is it i did not ask to do me my all homework bro

2

u/prashant13b Sep 28 '22 edited Sep 28 '22

Thats literally the purpose of assignment, if you are learning js , least you should know is how to read objects.

Hint : you can use for in loop , bind question and options to html for every q1,q2….

And why do you need local storage? What does importing local storage means ?

1

u/[deleted] Sep 28 '22

So then did you do it?