Exercise Weekend

Now you have all the tools you need to make more complicated decisions in your code. Let's do some examples.

  • You have a friend who can't eat "fish" or "pineapples". Write a function using && to check if she can eat a particular kind of food or not. Return one sentence if she can eat it, and a different one if she can't. For example, the function might work like this: canEllaEat("panda stew"); would return "She can eat it!".
  • Rewrite the previous function using || instead.
  • Let's add a new message to the number guessing game we made in the previous lesson. Since the rules of the game say that the user has to guess a winning number which will be between 1 and 20, make the program output "That's not between 1 and 20!" if the user guesses less than 1 or greater than 20.