Dogs and toys

Write an app that gives advice about the number of dog toys the user has. It starts like this:

Start

The user fills in the fields, and clicks Show advice. First, the app validates the input data. Make sure that:

  • Neither field is empty.
  • Neither field contains a negative number.

Show appropriate error messages. For example:

Error

Use the flag pattern so that all applicable error messages show. In this case, after the user clicks OK, another message would appear for dog toys.

If the data is OK, show some advice on the page. Show the advice below the button.

  • If there are more dogs than dog toys, show "You don't have enough dog toys! Get some more."
  • If there are more dog toys than dogs, show "You have enough dog toys. Good to go!"
  • If there the same number of dogs and dog toys, show "You have just enough dog toys, but no extra. Get some spares."

For example:

Advice

Submit the URL of your solution.

(If you were logged in as a student, you could submit an exercise solution, and get some feedback.)