Skip to content

Commit 220166d

Browse files
committed
Translate 'Storing a history of moves'
1 parent b7bc356 commit 220166d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/content/learn/tutorial-tic-tac-toe.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,19 +1729,19 @@ Lopullisena harjoituksena, tehdään mahdolliseksi "aikamatkustus ajassa taaksep
17291729
17301730
### Pelin siirtojen tallentaminen {/*storing-a-history-of-moves*/}
17311731
1732-
If you mutated the `squares` array, implementing time travel would be very difficult.
1732+
Jos mutatoit `squares` taulukkoa, aikamatkustuksen toteuttaminen olisi hyvin vaikeaa.
17331733
1734-
However, you used `slice()` to create a new copy of the `squares` array after every move, and treated it as immutable. This will allow you to store every past version of the `squares` array, and navigate between the turns that have already happened.
1734+
Kuitenkin, jos käytit `slice()`:a luodaksesi uuden kopion `squares` taulukosta jokaisen siirron jälkeen, ja käsitellä sitä muuttumattomana. Tämä antaa sinun tallentaa jokaisen edellisen version `squares` taulukosta, ja navigoida niiden välillä, jotka ovat jo tapahtuneet.
17351735
1736-
You'll store the past `squares` arrays in another array called `history`, which you'll store as a new state variable. The `history` array represents all board states, from the first to the last move, and has a shape like this:
1736+
Tallennat aikaisemmat `squares` taulukot toiseen taulukoon nimeltään `history`, jonka toteutat uutena tilamuuttujana. `history` taulukko edustaa kaikkia pelilaudan tiloja, ensimmäisestä viimeiseen siirtoon, ja sillä on tämän kaltainen muoto:
17371737
17381738
```jsx
17391739
[
1740-
// Before first move
1740+
// Ennen ensimmäistä liikettä
17411741
[null, null, null, null, null, null, null, null, null],
1742-
// After first move
1742+
// Ensimmäisen liikkeen jälkeen
17431743
[null, null, null, null, 'X', null, null, null, null],
1744-
// After second move
1744+
// Toisen liikkeen jälkeen
17451745
[null, null, null, null, 'X', null, null, null, 'O'],
17461746
// ...
17471747
]

0 commit comments

Comments
 (0)