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 Basics Making Decisions in Your Code with Conditional Statements The Conditional Challenge

I am struggling with these challenges

I am doing these JavaScript courses and I understand everything, but when given a challenge I am confused with where to start and need to search the web for answers on how to start, once I start then it becomes easier and can finish it. It makes me feel a bit unmotivated not knowing where to start with a challenge. Is this normal and will it become more clear overtime as I do the course?

1 Answer

Moira Lawrie-Martyn
Moira Lawrie-Martyn
8,073 Points

Whenever I'm starting with a complicated task in coding, I always start with the high level steps of the coding "recipe".

I use comments to lay out what I need to do, for example if I wanted to write a program to generate random numbers. I want to start with the highest level steps of the program:

// Write a function to generate the random number
// Write a function call and write the result to the console

Then I'll iterate on that, giving more detail to each step:

// Write a function to generate the random number
    // parameters will be the minimum and maximum numbers for the random
    // Return the Math.floor() number so it returns at maximum the integer below the highest provided
// Write a function call and write the result to the console
   // make sure the parameters are added

Then maybe some error handling

// Write a function to generate the random number
    // parameters will be the minimum and maximum numbers for the random
    // Return the Math.floor() number so it returns at maximum the integer below the highest provided
    // Add error handling in case the argument passed in is not a number
// Write a function call and write the result to the console
   // make sure the parameters are added

And so on. Once I've got all the comments and the pseudocode steps worked out for how I'm going to tackle this problem, then I start coding in the language and testing the outcomes.

It takes some practise to know what steps you need and break it down until you're ready to code but it also means you can walk away from your project and potentially work on other things then come back and you know where you need to pick it back up.

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Moderator edit: Changed response from Comment to Answer so it will be reflected in the Community as being answered.