Afrikaans
Akan
Albanian
Amharic
Arabic
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
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
0 All right. 1
So we want to be able to change both dice images when we click on any one of the buttons. In order to 2
do this, 3
we need both the rightDiceNumber and the leftDiceNumber to update when we click on any one of these 4
flat buttons. 5
The simple solution is to generate a new number for our leftDiceNumber and rightDiceNumber whenever 6
any of these buttons are pressed. 7
All we need to do is simply copy the behavior that we have for the rightDiceNumber over here, and we'll 8
copy that line of code for the leftDiceNumber down here. 9
So now whenever either of the buttons are pressed, we update the leftDiceNumber to a new random number. 10
We update the rightDiceNumber into a new random number, and we call set state on that to update the 11
image on both of these places. 12
Now when set state gets called, it sees that leftDiceNumber is used here 13
and rightDiceNumber is used here. 14
And it will redraw both of these images. 15
So let's give that a go. 16
Let's hit save. 17
And now when I click on the left side, the right side also changes. When I click on the right side, the 18
left side also changes. 19
Perfect. 20
That's exactly what we wanted. Now in this last challenge for Dicee, 21
I want you to use what you learned about functions or what you already know about functions, to remove 22
all of our repeated code because you can see we've got a lot of code that looks the same, 23
right? 24
How can you remove that and put it into a function so that you call the function instead when the buttons 25
get pressed? 26
So we don't have all of this code that looks identical to each other. 27
Pause the video and I'll share the solution with you in the next lesson.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.