Lesson 8
Problem-solving workflow
Build a practical mental model for problem-solving workflow and use it in working JavaScript.
By the end, you will be able to…
- Explain problem-solving workflow in your own words
- Use problem-solving workflow in a small program
- Recognize and debug a common failure mode
Build the mental model
Strong problem solvers do not start typing immediately. They restate the problem, work a small example by hand to find the pattern, sketch pseudocode, implement the simplest version that could work, then stress-test it against edge cases.
Syntax and working example
Read the code from inputs to output. Predict what it prints, then run it and change one value.
Why this matters
This workflow is exactly what technical interviews evaluate, and it is what separates 'I stared at the screen for an hour' from steady, visible progress on a hard problem.
Real-world example
Interviewers explicitly want to hear you restate the problem and discuss edge cases before you write any code — it demonstrates the same workflow.
Common mistakes
- Writing code immediately without a plan
- Skipping edge cases like empty input or a single item
- Never working a small example by hand to find the pattern
Try it yourself
Challenge
Apply the workflow: write pseudocode as comments, then implement a function that finds the sum of an array's even numbers.
Knowledge check
What should you typically do before writing any code for a new problem?
Summary
Restate, example, pseudocode, implement, test edge cases — a repeatable approach to any new problem.