30-Days-Of-JavaScript icon indicating copy to clipboard operation
30-Days-Of-JavaScript copied to clipboard

Day 3 exercise Level 2 question 14

Open Dhanuvarsha opened this issue 2 years ago • 2 comments

Write a script that prompt the user to enter number of years. Calculate the number of seconds a person can live. Assume some one lives just hundred years.

can anyone tell me the code

Dhanuvarsha avatar Jun 20 '22 07:06 Dhanuvarsha

Tried all possible ways still not getting expected result for this : Enter number of years you live: 100 You lived 3153600000 seconds.

Dhanuvarsha avatar Jun 20 '22 07:06 Dhanuvarsha

Just get the user input and then convert the number (years) into seconds by multiplying, nothing fancy. Just think about how many days has a year, how many hours has a day, how many minutes has a hour and last but not least, how many seconds has a minute.

const years = 100   //USER_INPUT_NUMBER
const seconds = years * 60 * 60 * 24 * 365; 

console.log(seconds);

Output:

>> 3153600000

Shooteger avatar Jul 07 '22 23:07 Shooteger