You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/learn/tutorial-tic-tac-toe.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1363,9 +1363,9 @@ On myös toinen etu muuttumattomuudessa. Oletuksena, kaikki lapsikomponentit ren
1363
1363
1364
1364
### Vuorojen ottaminen {/*taking-turns*/}
1365
1365
1366
-
It's now time to fix a major defect in this tic-tac-toe game: the "O"s cannot be marked on the board.
1366
+
Nyt on aika korjata suuri vika tässä ristinolla-pelissä: "0":a ei voi merkitä pelilaudalle.
1367
1367
1368
-
You'll set the first move to be "X" by default. Let's keep track of this by adding another piece of state to the Board component:
1368
+
Asetat ensimmäisen siirron oletuksena "X":ksi. Pidetään kirjaa tästä lisäämällä toinen tilamuuttuja `Board` komponenttiin:
1369
1369
1370
1370
```js {2}
1371
1371
functionBoard() {
@@ -1376,7 +1376,7 @@ function Board() {
1376
1376
}
1377
1377
```
1378
1378
1379
-
Each time a player moves, `xIsNext` (a boolean) will be flipped to determine which player goes next and the game's state will be saved. You'll update the `Board`'s `handleClick`function to flip the value of `xIsNext`:
1379
+
Joka kerta kun pelaaja siirtää, `xIsNext` (totuusarvo) käännetään määrittämään kumpi pelaaja siirtää seuraavaksi ja pelin tila tallennetaan. Päivität `Board` komponentin `handleClick`funktion kääntämään `xIsNext` arvon:
1380
1380
1381
1381
```js {7,8,9,10,11,13}
1382
1382
exportdefaultfunctionBoard() {
@@ -1400,15 +1400,15 @@ export default function Board() {
1400
1400
}
1401
1401
```
1402
1402
1403
-
Now, as you click on different squares, they will alternate between `X`and `O`, as they should!
1403
+
Nyt kun klikkaat eri neliöitä, ne vaihtelevat `X`ja `0` välillä, kuten niiden pitäisi!
1404
1404
1405
-
But wait, there's a problem. Try clicking on the same square multiple times:
1405
+
Mutta hetkonen, tässä on ongelma. Kokeile klikata samaa neliötä useamman kerran:
1406
1406
1407
-

The `X`is overwritten by an `O`! While this would add a very interesting twist to the game, we're going to stick to the original rules for now.
1409
+
`X`ylikirjoitetaan `0`:lla! Vaikka tämä lisäisikin mielenkiint0isen käänteen peliin, pysytään alkuperäisissä säännöissä toistaiseksi.
1410
1410
1411
-
When you mark a square with a `X` or an `O` you aren't first checking to see if the square already has a `X`or `O` value. You can fix this by *returning early*. You'll check to see if the square already has a `X`or an `O`. If the square is already filled, you will `return`in the `handleClick`function early--before it tries to update the board state.
1411
+
Kun merkitset neliön `X`:llä tai `0`:lla, et ensin tarkista onko neliöllä jo `X`tai `0` arvoa. Voit korjata tämän *palaamalla aikaisin*. Tarkistat onko neliöllä jo `X`tai `0` arvo. Jos neliö on jo täytetty, `return``handleClick`funktiossa aikaisin--ennen kuin se yrittää päivittää pelilaudan tilaa.
1412
1412
1413
1413
```js {2,3,4}
1414
1414
functionhandleClick(i) {
@@ -1420,7 +1420,7 @@ function handleClick(i) {
1420
1420
}
1421
1421
```
1422
1422
1423
-
Now you can only add `X`'s or `O`'s to empty squares! Here is what your code should look like at this point:
1423
+
Nyt voit lisätä vain `X` tai `0` tyhjille neliöille! Tässä on mitä koodisi tulisi näyttää tässä vaiheessa:
0 commit comments