All right, so this was a relatively simple exercise, but I'm going to quickly go through the solution 1
in case you got stuck and you wanted to see how it's done. 2
So the goal is very simple. 3
We want to be able to output this exact sentence, replacing the x, y and z with the actual number 4
of days, weeks and months we have left if we live until 90. 5
So in this case, our age is going to be passed in as an input to this function lifeInWeeks, and 6
we're going to be able to use it to do all of these calculations. 7
So here it tells us that we're assuming there's 365 days in a year, 52 weeks in a year and 12 months 8
in a year. 9
So we can use this information to calculate the days, weeks and months remaining. 10
So let's go ahead and do that. 11
We're saying that we're assuming that we'll live until 90. 12
So let's create a variable called yearsRemaining that's going to be set to 90 - age. 13
Now, once we've got the years remaining, then we can work out the number of days, weeks, and month 14
left. 15
So days = yearsRemaining * 365. 16
weeks = yearsRemaining 17
multiplied by 52. And finally months = yearsRemaining * 12. 18
So now that we've got all of our numbers, days, weeks and months and make sure that we haven't made 19
any typos anywhere, then we're ready to go ahead and console-log the output. 20
So I'm going to go ahead and type out this message, trying to make sure that I don't make any typos 21
and have the same capitalization. 22
So you have x days, y weeks and z months left. 23
Full stop. 24
So this is what I'm going to try and output and I'm going to replace each of these with the actual calculated 25
values. 26
So I'm going to delete the x, add some double quotes and then use some plus signs so that I can actually 27
concatenate the actual value of days. And then I'm just going to do this for the other parts. 28
So now that I think I've completed my code, I'm going to click on this link to go to my Repl.it playground 29
and I'm going to paste my code inside this function. 30
So now we can go ahead and call this function lifeInWeeks and pass in our actual age. 31
Let's say I am 12 and then we can click on Run to see if it actually works. 32
So if I was 12 years old, 90 - 12 is going to be equal to 78. 33
So the days remaining will be 78 multiplied by 365, which is twenty-eight thousand four hundred and 34
seventy. 35
The weeks remaining will be 78 multiplied by 52, which is 4,056. 36
And finally, the month remaining will be 78 multiplied by twelve, and that's 936 37
months. 38
So now that I've assured myself that my functions are working, I can go back and go ahead and click 39
on check solution. 40
And hopefully as long as my sentence matches the exact example output including all the spaces and 41
the capitalizations and all of the commas and full stops, then my solution should pass and I should 42
have completed this challenge. 43
So how did you get on? If you got stuck 44
go back to it and try to fix it so that it works.