How do you approach debugging a piece of code that isn't producing the expected output?

Technical