How to Solve a Code Challenge:
- Research that week’s method or concept.
- What method or concept are we learning about this week?
- Look it up on MDN or w3schools.
- Search for articles on Medium about the method/topic.
- Watch a YouTube video on it.
- Review your Lecture Notes from class.
- Participate in discussions with other developers about the code challenge.
- Understand the problem.
- Read through the problem.
- Identify suggestive key words/hints.
- Identify the requirements for solving the challenge.
- Identify the inputs.
- Inputs are the arguments our function will take in when it is called.
- Identify the outputs.
- Outputs are what we are expecting our function to return back to us when it is finished running.
- View the test for input/output examples.
- Create a step-by-step plan (algorithm) for how you’ll solve it.
- Think about how this week’s method/topic can be applied to solve the code challenge.
- Create a visual example with inputs (like a whiteboard) to help wrap your brain around each step your function is taking.
- Create a checklist (in plain English) of everything this function needs to accomplish.
- You’ve already identified the requirements in the step above. Now all you have to do is fill in the tiny details.
- The most practical way of creating an algorithm is often to focus on the example input/output in your visual.
- You should consider the steps that your algorithm will take to use the input in moving towards the output.
- This process of working through the problem yourself, and noticing the steps you take along the way, should naturally help you flesh out the steps that will be part of your algorithm.
- Carry out the plan and write actual code.
- Using your algorithm checklist, write code that will accomplish one task at a time.
- Complete your function.
- Correct any syntax/linter errors.
- Don’t forget to return your solution!
- Get the test to pass.
- Look back and possibly refactor your solution if it could be better.
- Is the test for this code challenge passing?
- Does your solution meet all the requirements for this code challenge?
- Does your solution use this week’s method/topic to solve the code challenge?
- Can you understand it at a glance? Does it make sense? Is it readable?
- Try explaining your code out loud (or in your head). Are there any parts you struggle with?
- Can you think of other ways to refactor? Make it a one-liner?
- How have other people solved this problem?
- Are there any “weird” or “bad” inputs that could break your code?
Resources