This JavaScript code is a simple representation of fruits and a basket. It defines a Fruit
class to create fruit objects with properties like name, color, and taste. It also defines a Basket
class to store instances of fruits.
- Clone the repository or copy the
fruits.js
file into your project. - Include
fruits.js
in your HTML file using a<script>
tag. - Run your HTML file in a web browser to see the output in the console.
- The
Fruit
class represents a fruit with properties like name, color, and taste. It has a methoddescribe()
to log information about the fruit. - Several fruit objects like apple, banana, orange, and grape are created using the
Fruit
class. - The
Basket
class stores instances of fruits in an array and has methods to add fruits and describe the fruits in the basket. - A basket is created, and fruits are added to it. Finally, the fruits in the basket are described.
This code is provided under the MIT License. Feel free to use and modify it for your projects.