All language subtitles for 12. Challenge 2 Solution

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French Download
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 0 1 00:00:00,710 --> 00:00:01,010 All right. 1 2 00:00:01,040 --> 00:00:06,900 So we want to be able to change both dice images when we click on any one of the buttons. In order to 2 3 00:00:06,900 --> 00:00:07,690 do this, 3 4 00:00:07,700 --> 00:00:16,700 we need both the rightDiceNumber and the leftDiceNumber to update when we click on any one of these 4 5 00:00:16,820 --> 00:00:18,520 flat buttons. 5 6 00:00:18,530 --> 00:00:27,290 The simple solution is to generate a new number for our leftDiceNumber and rightDiceNumber whenever 6 7 00:00:27,590 --> 00:00:29,430 any of these buttons are pressed. 7 8 00:00:29,660 --> 00:00:36,320 All we need to do is simply copy the behavior that we have for the rightDiceNumber over here, and we'll 8 9 00:00:36,320 --> 00:00:39,590 copy that line of code for the leftDiceNumber down here. 9 10 00:00:40,070 --> 00:00:47,900 So now whenever either of the buttons are pressed, we update the leftDiceNumber to a new random number. 10 11 00:00:47,930 --> 00:00:54,440 We update the rightDiceNumber into a new random number, and we call set state on that to update the 11 12 00:00:54,620 --> 00:00:57,940 image on both of these places. 12 13 00:00:57,950 --> 00:01:03,440 Now when set state gets called, it sees that leftDiceNumber is used here 13 14 00:01:03,440 --> 00:01:05,360 and rightDiceNumber is used here. 14 15 00:01:05,570 --> 00:01:09,270 And it will redraw both of these images. 15 16 00:01:09,350 --> 00:01:10,640 So let's give that a go. 16 17 00:01:10,670 --> 00:01:11,850 Let's hit save. 17 18 00:01:11,900 --> 00:01:19,400 And now when I click on the left side, the right side also changes. When I click on the right side, the 18 19 00:01:19,400 --> 00:01:21,440 left side also changes. 19 20 00:01:21,440 --> 00:01:22,070 Perfect. 20 21 00:01:22,070 --> 00:01:27,570 That's exactly what we wanted. Now in this last challenge for Dicee, 21 22 00:01:27,570 --> 00:01:34,290 I want you to use what you learned about functions or what you already know about functions, to remove 22 23 00:01:34,410 --> 00:01:39,570 all of our repeated code because you can see we've got a lot of code that looks the same, 23 24 00:01:39,600 --> 00:01:40,700 right? 24 25 00:01:40,710 --> 00:01:47,820 How can you remove that and put it into a function so that you call the function instead when the buttons 25 26 00:01:47,880 --> 00:01:48,790 get pressed? 26 27 00:01:48,870 --> 00:01:53,690 So we don't have all of this code that looks identical to each other. 27 28 00:01:53,730 --> 00:01:57,230 Pause the video and I'll share the solution with you in the next lesson. 2778

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.