Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics Making Decisions in Your Code with Conditional Statements The Conditional Challenge

Tomislav Catalinac
seal-mask
.a{fill-rule:evenodd;}techdegree
Tomislav Catalinac
Full Stack JavaScript Techdegree Student 1,015 Points

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
7,818 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,541 Points

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