Coding task · JavaScript and TypeScript course · Module 2: Functions, Arrays and Objects
Exercise: Write a Function to Calculate Fossil Age
A million is 1000000, so the age in millions of years is years / 1000000. Math.round() rounds to the nearest whole number, and the function gives back the result with return.
Task
Write a function ageInMillions(years) that returns the age of a fossil in millions of years, rounded to a whole number with Math.round(). Call it for a fossil that is 66000000 years old and display the result in the console.