Week 8 Assignment B - COIN 70a

Food Quiz

Got a Cookbook?

CODE:
answer = prompt("Do you have a cookbook?", "");
if (answer.toLowerCase() == "yes") {
	alert("May I borrow it?");
} else if (answer.toLowerCase() == "no") {
	alert("Too bad.  Would you like to borrow mine?");
} else {
	alert("Sorry, your answer doesn't compute!");
}

Instructions


Let's combine this IF/ELSE exercise with a little bit of error checking using logical operators.
You're working for the Food Network and on the website, you've written a program which has an
interaction with a user...in this part, you're asking if she has a cookbook. She could say Yes or
she could say yes or she could say YES or she could say No in any variety of ways. How can you write
the IF to accept any of those options and give an appropriate response in either case?
PS JUST use IF/ELSE to solve this. You may know other methods, but practice with IF/ELSE.
Filename: 8b.html

BACK