Note that we have not defined the variable my_sum and try to print the value by using document.write. For your learning we have defined the variable and commented this line , you can uncomment and check the difference.
We can display the error message which has caused the exception by error object. Here internet explorer and firefox behaves differently so we have to identify the browsers and then display the message accordingly through an alert box.
This article is written by plus2net.com team.
|More on Loops and Variables|