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 let's try to tackle this challenge.
Step by step.
Now if we look at the flow chart the first question we ask is Is it cleanly divisible by four.
If no then it's definitely not a leap year.
If yes then we have to ask more questions.
So how would we write this in terms of code.
Well we'd probably use an if statement to check if the year that were being passed in here is cleanly
divisible by four.
And remember that on a previous lesson which I linked to here we learned about the modulo operator which
gives you the remainder of a division.
So if the year modulo four is equal to zero namely if there is no remainder when you divide the year
by four.
Well in that case then it's likely to be a leap year.
But if it's not even divisible by four then it's definitely not a leap year.
So here we could simply return not leap year.
So any year that is not divisible by four.
That is definitely not a leap year but if it is divisible by four we still have to check is it cleanly
divisible by 100.
Because if no then it's definitely a leap year.
But if yes then we have to check further.
So the best way to represent that logic is to create another if statement inside this if statement.
So it's already divisible by four.
But we have to check whether if it's divisible by 100.
So if the year modulo 100 is equal to zero Well then we have to make some further checks.
But if it's not then it's definitely a leap year.
So we can return leap year.
Now finally we're in the homestretch and we have to ask ourselves the last question is it cleanly divisible
by 400.
If no then it's not a leap year.
If yes then it is a leap year.
So inside this if statement we're going to ask ourselves one further question if the year is divisible
by 400.
And that has no remainder.
Well then it's definitely a leap year.
And if that's not true then it's definitely not a leap year.
So this is the logic that we saw in the flowchart mapped out with javascript code and going from these
words to code is actually quite a big jump.
But going via that middle ground that flowchart makes it so much easier to actually map out the logic
and then converting it into code.
So hope you enjoy that challenge and you managed to get it right and at least if you didn't you saw
how you can use flow charts to simplify and clarify your own idea of the logic because at the end of
the day the code is easy.
But the logic is the path that you've got to get right first.
So now if we check our solution then everything should pass.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.