Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
All right.
So this was a relatively simple exercise but I'm going to quickly go through the solution in case you
got stuck and you wanted to see how it's done.
So the goal is very simple.
We want to be able to output this exact sentence replacing the X Y and Z with the actual number of days
weeks and months.
We have left.
If we live until ninety two in this case our age is going to be passed in as an input to this function
life in weeks and we're going to be able to use it to do all of these calculations.
So here it tells us that we're assuming there's 365 days in a year 52 weeks in a year and 12 months
in a year.
So we can use this information to calculate the days weeks and months remaining.
So let's go ahead and do that.
We're saying that we're assuming that we'll live until 90.
So let's create a variable called years remaining that's going to be set to 90 minus age.
Now once we've got the years remaining then we can work out the number of days weeks a month left.
So days equals years remaining multiplied by 365 weeks equals years remaining multiplied by 52.
And finally months equals years remaining multiplied by 12.
So now that we've got all of our numbers days weeks and months and make sure that we haven't made any
typos anywhere then we're ready to go ahead and console log the output.
So I'm going to go ahead and type out this message trying to make sure that I don't make any typos and
have the same capitalization.
So you have X days y weeks and Z months left full stop.
So this is what I'm going to try and output and I'm going to replace each of these with the actual calculated
values.
So I'm going to delete the X at some double quotes and then use some plus signs so that I can actually
concatenate the actual value of days and then I'm just gonna do this for the other parts
so now that I think I've completed my code I'm going to click on this link to go to my Rapley playground
and I'm going to paste my code inside this function.
So now we can go ahead and call this function life in weeks and pass in our actual age.
Let's say I am 12 and then we can click on run to see if it actually works.
So if I was 12 years old 90 minus 12 is going to be equal to 78.
So the days remaining will be 78 multiplied by three six five which is twenty eight thousand four hundred
and seventy.
The weeks remaining will be 78 multiplied by 52 which is four thousand fifty six.
And finally the month remaining will be 78 multiplied by twelve.
And that's nine hundred and thirty six months.
So now that I've assured myself that my functions working I can go back and go ahead and click on check
solution and hopefully as long as my sentence matches the exact example output including all the spaces
and the capitalizations and all of the commas and full stops then my solution should pass and I should
have completed this challenge.
So how did you get on if you got stuck go back to it and try to fix it so that it works.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.