Skip to main content

Command Palette

Search for a command to run...

Convert Age to Days

Published
1 min read
Convert Age to Days
D

I am a Web Developer from Birtamode 1 Jhapa Nepal. As of 2022 i have 3 years of experience in CSS and 1 year of experience in Javascript + 6 Months of Experince in Node.js

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.

    Javascript

    function convert(a) {
      if (a >= 0) {
          return a * 365;
      } else {
          console.log("Wrong input");
      }
    }
    let age = 99;
    console.log(convert(age));
    

More from this blog

D

Dipesh Murmu

46 posts

A Full-Stack Laravel Developer with expertise in HTML, CSS, JavaScript, Tailwind, and core PHP. Leveraging the power of Laravel, I specialize in creating dynamic and responsive web applications.