Now that you know
if-statements, I’m going to give you some rules for
while-loops that will keep you out of trouble. I’m also going to give you some tips on debugging so that you can figure out problems with your program. Finally, you will design a little game similar to the last exercise, but with a slight twist.
if-statement must have an
2. If this
else should never run because it doesn’t make sense, then you must use a
die function in the
else that prints out an error message and dies, just like we did in the last exercise. This will find many errors.
3. Never nest
if-statements more than two deep and always try to do them one deep.