You are managing a fruit basket, represented as an array of fruits. Your task is to perform several operations on this basket.
-
Print to the console the total number of fruits in the format "Total number of fruits in the basket is <count>"
-
Add a new fruit "Mango" at the end of the array using the appropriate array method.
-
Remove the first fruit from the array using the appropriate array method and print the removed fruit's name to the console in the format "Removed fruit: <fruitname>."
-
Check if the first value in the array is "Apple". If it is, print to the console "Apple is the first fruit the basket." Otherwise, print "Apple is not the first fruit in the basket."
-
Add a new fruit "Strawberry" to the beginning of the basket using the appropriate array method.
-
Print to the console the array in the format "Final fruit basket: "
We are not displaying the answer for this exercise.
We do this because we want you to challenge yourself
and
not give in to the temptation of looking at the solution.
We also don't want to leave you stuck, so if you feel
you have tried enough and are still unable to solve
this exercise, feel free to ask in our community.
Here is the link to join the community.