Coding task · JavaScript and TypeScript course · Module 1: JavaScript Basics

Exercise: Write a Function to Calculate Fossil Age

The function receives data through parameters and gives back the result with return. For the T-Rex the result is 68.002024.

Task

Write a function calculateFossilAge(currentYear, fossilYear) that returns the fossil's age in millions of years: (currentYear - fossilYear) / 1000000. Write years BC as negative numbers. Call it for a T-Rex (2024, -68000000) and display the result in the console.