Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active May 6, 2022 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/c19a568b71b6a8329d8e8c8c5f71d5f8 to your computer and use it in GitHub Desktop.
Save McLarenCollege/c19a568b71b6a8329d8e8c8c5f71d5f8 to your computer and use it in GitHub Desktop.
Farm Animals

Below is a farmAnimals object with many animals and number of legs that animal have. Given a particular animal, find the total number of legs of that animal in farm.

let farmAnimal = {
    chicken: { legs: 2, count: 2 },
    cow: { legs: 4, count: 1 },
    pig: { legs: 4, count: 2 },
    ostrich: { legs: 2, count: 4 },
    zebra: { legs: 4, count: 3 },
}

let animal = 'chicken';
let legCount = //expression
console.log(legCount);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment