You are here: Home / Topics / Convert Age to Days in JavaScript

Convert Age to Days in JavaScript

Filed under: JavaScript on 2023-08-06 20:43:43

Create a function that takes the age in years and returns the age in days.

Examples:

calcAge(65) ➞ 23725

calcAge(0) ➞ 0

calcAge(20) ➞ 7300

 

Notes:

  • Use 365 days as the length of a year for this challenge.
  • Ignore leap years and days between last birthday and now.
  • Expect only positive integer inputs.

 

<script>

function calcAge(year){

return year*365;

}

calcAge(65) //output 23725

calcAge(0) //output 0

calcAge(20) //output 7300

</script>

About Author:
M
Mr. Dubey     View Profile
Founder and CEO of MCQ Buddy. I just like to help others. This portal helps students in getting study material free.