1 - Use the Compiler
The compiler is a great friend when it comes to debugging your code. pay attentions to warnings and errors. Any errors that come up can usually be linked to the exact line of code in the source. Often, syntax errors will be on the line above or in previous lines of codes. Look out for missing quotes, brackets, braces and semicolons.
2 - Bow to the Wisdom of the Rubber Duck
When you encounter an issue, explain it out loud and in detail to a rubber duck or other inanimate object. The act of speaking and having to explain the problem will often make the solution present itself.
3 - Assume Nothing
Most programming bugs are caused by incorrect assumption on the part of the programmer. Document your assumptions. Remember to convert assumptions into facts using testing and assertions because it's not a fact until you can prove it.
4 - Build a Minimum Viable Test Case
By removing all code not related to the issue, the problem becomes easier to reason about. Creating a Minimum Viable Test Case is also a great thing to do to save other people's time if you ask for help.
5 - Use the Scientific Method
Form an hypothesis about what is causing your bug. Make a testable prediction according to your hypothesis. Create a test for your prediction. Repeat by forming a new hypothesis or making a new prediction.
Hope you'll find these five tips useful when you hit a bug in your code!
Until next time, Happy coding :)