Approaching problems
When approaching coding problems, it can be helpful to follow a process. We recommend a four-step approach:
- Understand the problem
- Write Pseudocode
- Write JavaScript
- Refactor
Understand the problem
First, make sure you understand the problem you’re working on. What is it asking you to do? Look at the parts of the problem and break it down into manageable steps.
Write Pseudocode
Break the problem down into key steps - each one should be one or two sentences. Translate the problem into steps that you understand.
Use JavaScript comments to write out these steps in order.
Write JavaScript
Following your pseudocode, code each step. Translate the pseudocode into JavaScript.
Refactor
Once you’ve coded a solution, reflect on what you wrote.
What can you change about your code to make it more efficient? How might you solve the problem differently?
Tips
- Use
console.log()
often - Re-read the problem
- Check your inputs and outputs
- Check for syntax errors
- Read any error messages
- Look at documentation such as W3 Schools or MDN