Coding Challenge: Components

Test the skills learned in this chapter by taking the coding challenge.

We'll cover the following

Problem

In the below-provided application, a demo website containing information about some animals for children is presented.

In the application, three components: Cat, Dog, and Rabbit are defined. All three components have three data variables: name, numLegs, and animalType. The name of the three animals is different but their numLegs and animalType are the same since this application is displaying domestic animals having four legs.

Observe that the numLegs and animalType variables are repeated in all three components. However, this can be done in a better way so that the code can be more compact and future changes can be done easily and without changing every component individually.

Please run the application below and observe the code.

Get hands-on with 1400+ tech skills courses.