Due Monday Nov 4 at 11:59pm.
Carefully study the examples on the resources page: Javascript conditionals and combining conditionals.
Copy/paste the source code of this page into a file
pictures.html
.
Add a conditional that, depending on the person's answer, displays one
of the two pictures. More specifically:
Hints:
alt
attribute for an imageChange the program so that the lower-case y and n are also accepted as an answer. Do not add extra if/else, use || (means "or") instead. You need to write out both conditions and then connect them with ||. For instance,
if (n == 4 || n == 5) // correct
is correct, but this is wrong:
if (n == 4 || 5) // WRONG!
Write a program that uses a random number generator (see here) to generate a random number between 1 and 5. Then display one of six fortune messages, depending on the number. For instance, if the number is 2, your message might be "This is the luckiest day of your life!". Run your program several times to make sure it works.
Change your fortune-teller to increase the range of your numbers and make some messages more frequent than others by making them show up for more than one number. For instance, 1, 2, and 3 may all give you the same message, 4 and 5 give you a different one, and so on. Make sure that even the least frequent messages show up if you try your program long enough.
This page is a part of CSci 1001 course web site.