Most modern browsers have developer tools that allow you to debug JavaScript, and they will usually give you the exact line on which the error occurs. This is a pretty simple one, so it’s a good opportunity to sharpen your debugging skills. These will be invaluable later on.
The next basic debugging step is to test your logic. Put a few alert() statements throughout your code to check that your if tests are working and/or functions are being called correctly.
Also whack a couple in your externally referenced js files at the top to make sure they’re being loaded.
Don’t you think it’s more helpful to teach people problem solving skills, or introduce them to tools and resources that can help them become more effective at identifying errors and solving them?
Apologies for taking this thread OT a bit, but it’s the sort of thing I see here over and over again and I think it just perpetuates the cycle of “Why my codes no werk?!?!!”
[QUOTE=disgracian;4474195]Don’t you think it’s more helpful to teach people problem solving skills, or introduce them to tools and resources that can help them become more effective at identifying errors and solving them?
That we certainly do, when the audience is ready for them. Many is the time when error consoles and resources such as jslint.com are put forward to help and assist people.
The other side of things that we do here is to help people move away from deprecated techniques, where we show them improved ways of handling things. This information then stays around for other people when they are searching for similar solutions.
While I know that also happens, I seem to see a lot more of people just doing the work for them. I know because I try to gently guide people to figuring it out for themselves and I never seem to be able to get there before somebody just hands it to them on a platter.