Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,720 --> 00:00:00,980
All right.
2
00:00:01,020 --> 00:00:07,170
So this was a relatively simple exercise but I'm going to quickly go through the solution in case you
3
00:00:07,170 --> 00:00:09,570
got stuck and you wanted to see how it's done.
4
00:00:10,260 --> 00:00:12,400
So the goal is very simple.
5
00:00:12,420 --> 00:00:19,920
We want to be able to output this exact sentence replacing the X Y and Z with the actual number of days
6
00:00:19,920 --> 00:00:21,100
weeks and months.
7
00:00:21,120 --> 00:00:21,780
We have left.
8
00:00:21,810 --> 00:00:29,040
If we live until ninety two in this case our age is going to be passed in as an input to this function
9
00:00:29,040 --> 00:00:34,220
life in weeks and we're going to be able to use it to do all of these calculations.
10
00:00:34,230 --> 00:00:41,340
So here it tells us that we're assuming there's 365 days in a year 52 weeks in a year and 12 months
11
00:00:41,340 --> 00:00:42,050
in a year.
12
00:00:42,120 --> 00:00:47,220
So we can use this information to calculate the days weeks and months remaining.
13
00:00:47,220 --> 00:00:48,990
So let's go ahead and do that.
14
00:00:49,020 --> 00:00:52,100
We're saying that we're assuming that we'll live until 90.
15
00:00:52,200 --> 00:00:58,880
So let's create a variable called years remaining that's going to be set to 90 minus age.
16
00:00:58,920 --> 00:01:04,930
Now once we've got the years remaining then we can work out the number of days weeks a month left.
17
00:01:04,950 --> 00:01:20,000
So days equals years remaining multiplied by 365 weeks equals years remaining multiplied by 52.
18
00:01:20,210 --> 00:01:27,240
And finally months equals years remaining multiplied by 12.
19
00:01:27,800 --> 00:01:33,170
So now that we've got all of our numbers days weeks and months and make sure that we haven't made any
20
00:01:33,170 --> 00:01:38,960
typos anywhere then we're ready to go ahead and console log the output.
21
00:01:38,960 --> 00:01:44,540
So I'm going to go ahead and type out this message trying to make sure that I don't make any typos and
22
00:01:44,540 --> 00:01:46,670
have the same capitalization.
23
00:01:46,670 --> 00:01:55,480
So you have X days y weeks and Z months left full stop.
24
00:01:55,490 --> 00:02:02,240
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
00:02:02,240 --> 00:02:02,800
values.
26
00:02:02,920 --> 00:02:09,560
So I'm going to delete the X at some double quotes and then use some plus signs so that I can actually
27
00:02:09,560 --> 00:02:15,290
concatenate the actual value of days and then I'm just gonna do this for the other parts
28
00:02:18,240 --> 00:02:24,030
so now that I think I've completed my code I'm going to click on this link to go to my Rapley playground
29
00:02:24,150 --> 00:02:27,750
and I'm going to paste my code inside this function.
30
00:02:27,750 --> 00:02:34,470
So now we can go ahead and call this function life in weeks and pass in our actual age.
31
00:02:34,500 --> 00:02:41,240
Let's say I am 12 and then we can click on run to see if it actually works.
32
00:02:41,250 --> 00:02:46,980
So if I was 12 years old 90 minus 12 is going to be equal to 78.
33
00:02:47,280 --> 00:02:55,910
So the days remaining will be 78 multiplied by three six five which is twenty eight thousand four hundred
34
00:02:55,910 --> 00:02:57,210
and seventy.
35
00:02:57,300 --> 00:03:04,690
The weeks remaining will be 78 multiplied by 52 which is four thousand fifty six.
36
00:03:04,740 --> 00:03:10,230
And finally the month remaining will be 78 multiplied by twelve.
37
00:03:10,720 --> 00:03:14,040
And that's nine hundred and thirty six months.
38
00:03:14,040 --> 00:03:21,000
So now that I've assured myself that my functions working I can go back and go ahead and click on check
39
00:03:21,000 --> 00:03:30,150
solution and hopefully as long as my sentence matches the exact example output including all the spaces
40
00:03:30,210 --> 00:03:37,410
and the capitalizations and all of the commas and full stops then my solution should pass and I should
41
00:03:37,410 --> 00:03:38,940
have completed this challenge.
42
00:03:38,940 --> 00:03:44,300
So how did you get on if you got stuck go back to it and try to fix it so that it works.
4361
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.