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!
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
Jeff EnglandCourses Plus Student 631 Points
Trouble starting my first quiz application
Any help is appreciated!
Erik Nuber20,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.
You can check how this code is being done with steps.
- HTML Structure
- CSS Design
- Create tags and load ( function called when window loads )
- Load questions & answer ( array and display on dom with current array index )
- Check answers ( match question, response and correct answer from array )
- 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.