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 JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Build a Quiz Challenge, Part 1 Solution

J V
J V
3,414 Points

Build A Quiz Challenge: What advice do you recommend when programming and problem solving?

As I have been completing each section, I am able to code and perform on the code challenges and quizzes. When it comes to problem solving and writing code to create a program, I tend to get lost and confused on how to start.

For example, for this quiz build, I decided to write prompt statements to prompt the user with questions to answer. Then I decided to write the two-dimensional array, and I wanted to use a function that had a for loop within it, and then I got confused on how to make the code flow properly or work.

I had to stop and watch the solution video. It seems that the instructor makes everything seem simpler and easier than it really is to be.

Any suggestions or tips. Maybe it just takes constant and repetitive practice.

For those who answer, I appreciate your answers.

Thank You.

2 Answers

rydavim
rydavim
18,813 Points

I find it helpful to write psudo-code using comments before I start actually writing the program.

I usually start with a section at the top for variables. What things will I need to save or access during my program? I'll frequently add to this list as I figure out what steps I'll need to do to solve the problem.

Then I try to focus on the bigger problems. For a quiz application I might need to; iterate over each question and answer; get and save the user's answer to each question; check if they gave the correct answer or not; display the results. I would start there and slowly elaborate on each step.

I know I need to iterate over the quiz items - how might I do that? I could add a for loop, and then I could do the prompts and checks inside it.

I know I need to display the current question, and save the user's answer - how might I do that? I could use a variable to save a prompt response to the current question.

Basically, I try to focus on the bigger chunks of code I need to write. It's easier for me to work outside-in in terms of code blocks. The more tabs it's nested - the later I need to worry about it. Don't be afraid to call functions or blocks you haven't written yet. Add them, comment what you plan to do, and worry about how to do it once you've planned out the whole program.

Anyway, that's my two cents - happy coding!

J V
J V
3,414 Points

Hi Rydavim,

I appreciate the input. I will use your advice in the future when I program. Thank you.