May be it is possible my answer is duplicate. But I will tell the basic debugging technique that will make you understand what exactly is happening at runtime.
In your chrome(Mostly I used chrome to debug javascript) go to source code tab and on the javascript file see where you are not getting the expected result.
put breakpoint and see what are the things you are getting in watchlist for expected value.
you can just select the complete expression - right click and select add to watchlist.
while the control is on your break point you have the runtime variables alive in that scope.
Now just go to the console and type the variable, expression, or anything which you want to print to see it's value.
for more info check chrome developer tool