Coding task · JavaScript and TypeScript course · Module 1: JavaScript Basics
Practice: Functions
Program a dinosaur feeding schedule system. Create a function that will calculate the appropriate food portions based on the dinosaur's species and weight.
Task
Write a function calculateFoodPortion(diet, weightKg) that returns the daily food portion in kg: 5% of the weight for the 'carnivore' diet, 3% for 'herbivore' and 4% for 'omnivore'. Call it for a T-Rex ('carnivore', 8000) and display the result in the console.