Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Project JavaScript C1 Conditional Statements

Topics: The if keyword, if...else statements comparison operators logical operators, Truthy and falsy, Truthy and falsy assignment ternary operator, Else if statements, The switch keyword

Project Title: Dog Food Recommender

  1. Create a html file with your name like john.html
  2. Add current code to that file:
<!DOCTYPE html>
      // your code here
  1. Define variables for dog attributes:
  • Size: Small
  • Energy: Medium
  • Height: 9 inches

Height is number.

  1. Recommend Dog Food based on this conditions:
  • If Size is Small and Height < 9, Log "Food: Dry Dog Food"
  • If Size is Medium or Height > 12, Log "Food: Dehydrated Dog Food"
  • If Size is Big and Height >17 9, Log "Food: Raw Dog Food"
  • If None of them, Log "Canned Dog Food"
  1. Define variables for dog breed:
  • Breed: Affenpinscher
  1. Recommend Dog Food based on dog breed:
  • If Affenpinscher, Log "Dry"
  • If Akita, Log "Dehydrated"
  • If Cesky Terrier, Log "Raw"
  • If Chihuahua, Log "Canned"

Use switch case for this task.

Want to get reviewed?

Send Pull Request. Check how to deliver your code:

Need help?

Download Learn JavaScript eBook from

You can’t perform that action at this time.