Take your previous script and add comments explaining what each line does. Use both single-line (//) and multi-line (/* */) comments.
Then use a multi-line comment to temporarily disable some of your code. Refresh the page and confirm those lines no longer run. Remove the comment to re-enable the code. This technique helps when debugging.