Wednesday, January 30th, 2008
Formatting an If Statement
JavaScript does comparisons using == and === and does assignments using =. When you are coding your if statements you might accidentally leave out an = converting your comparison into an assignment. You might then have a great deal of difficulty in locating why your code is not behaving as expected. In this sixth tutorial on JavaScript decision making we look at how you can rearrange the condition tests in some instances so that the code will generate a syntax error when you make a simple typo when typing your comparison rather than having the code still run but producing the wrong results. This will make it easier to find where you made the error.
Tags: assignments, comparisons, decision making, javascript





