Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Jeff England
PLUS
Jeff England
Courses Plus Student 631 Points

Trouble starting my first quiz application

So I've been studying JavaScript for a while now(2 months with some on and offs) and I feel for the most part I have the basics of how to do JavaScript.

I'm having major trouble putting the knowledge in actual applications. I followed along this path: http://javascriptissexy.com/how-to-learn-javascript-properly/ after doing treehouse's JS series, at the end it has you try to build a quiz app but despite what I know it feels like I have no idea how to even start which is frustrating. Any tips for how to go about starting a quiz program in steps or however would be very helpful! No code necessary as I do want to be able to do it on my own as much as possible, I just need it explained in written form.

Any help is appreciated!

2 Answers

Erik Nuber
Erik Nuber
20,629 Points

This was using all the skills you learned up to that point. Creating a two dimensional array or an array of objects to hold your Q & A's.

At least for somewhat of a guide,

1) You need to use the prompt command to ask the question and store the answer into a variable.

2) You need to check the answer given to the answer stored. You should remember about case sensitivity and use toLowerCase or toUpperCase

3) Check to see if the answer is either null or quit (I don't remember if that was necessary in the lesson or not)

3.5) if the answer is correct you increase the score and possibly store either the question or index into an array so you can access the questions they got correct

4) if the answer is wrong you need to store the answer or index number into an array so you can access the questions they got wrong

5) when done, you need to print to screen the score and if you want to print the questions they got correct and didn't get correct. You can do this with a single variable that you build on using the += to continue adding in more information.

This is a real skeletal outline but, I know you can do it. It seems frustrating at first but, when you figure it out little by little you will feel great when you finish. Remember to use the console to check things as you code so you know if what you think is happening is actually happening.

jag
jag
18,266 Points

You can check how this code is being done with steps.

tl;dr

  1. HTML Structure
  2. CSS Design
  3. Create tags and load ( function called when window loads )
  4. Load questions & answer ( array and display on dom with current array index )
  5. Check answers ( match question, response and correct answer from array )
  6. Change style to indicate correct / wrong. ( changing dom)

There are a lot of ways you can make a quiz just break the problem into steps.