When syntax or runtime errors occur and scripts fail to execute, you must debug the code. Preventing errors is preferable to finding and fixing errors. Therefore, observe carefully the protocols required by JavaScript.