30-Days-Of-JavaScript
30-Days-Of-JavaScript copied to clipboard
Day 3 exercise Level 2 question 14
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
Tried all possible ways still not getting expected result for this : Enter number of years you live: 100 You lived 3153600000 seconds.
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