No one is perfect, and it often takes several iterations before the desired outcome is achieved. You have to peek into the code in real time to identify certain failure points. Debugging is a skill and can only be mastered with practice.
There are two styles of debugging that people use:
- Using developer tools: This is a more useful way to debug your code by adding breakpoints, watching, and...