Skip to content

Commit 1ece78f

Browse files
committed
docs: translate second section
1 parent c259560 commit 1ece78f

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/content/learn/rendering-lists.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ Warning: Each child in a list should have a unique "key" prop.
9595

9696
Anda akan mempelajari cara memperbaiki kesalahan ini nanti. Untuk saat ini, kita akan menambahkan struktur ke data Anda.
9797

98-
## Filtering arrays of items {/*filtering-arrays-of-items*/}
98+
## Menyaring seranai {/*filtering-arrays-of-items*/}
9999

100-
This data can be structured even more.
100+
Kita bisa menambahkan struktur ke data ini.
101101

102102
```js
103103
const people = [{
@@ -121,19 +121,19 @@ const people = [{
121121
}];
122122
```
123123

124-
Let's say you want a way to only show people whose profession is `'chemist'`. You can use JavaScript's `filter()` method to return just those people. This method takes an array of items, passes them through a “test” (a function that returns `true` or `false`), and returns a new array of only those items that passed the test (returned `true`).
124+
Misalkan Anda hanya ingin menampilkan orang yang memiliki profesi `'chemist'`. Anda dapat menggunakan *method* `filter()` dari JavaScript untuk mendapatkan daftar tersebut. *Method* ini menerima masukan berupa sebuah seranai, kemudian menguji setiap anggota dari seranai tersebut dengan sebuah fungsi uji (fungsi yang hanya mengembalikan nilai `true` (benar) atau `false` (salah)), lalu mengembalikan sebuah seranai baru yang terdiri atas anggota-anggota yang lolos uji (memperoleh nilai `true`).
125125

126-
You only want the items where `profession` is `'chemist'`. The "test" function for this looks like `(person) => person.profession === 'chemist'`. Here's how to put it together:
126+
Anda hanya menginginkan orang yang memiliki `profession` berupa `'chemist'`. Oleh karena itu, fungsi ujinya adalah `(person) => person.profession === 'chemist'`. Langkahnya seperti berikut:
127127

128-
1. **Create** a new array of just “chemist” people, `chemists`, by calling `filter()` on the `people` filtering by `person.profession === 'chemist'`:
128+
1. **Buatkan** sebuah seranai baru yang terdiri atas orang-orang berprofesi `chemists`, dengan memanggil *method* `filter()` terhadap seranai `people` dengan syarat `person.profession === 'chemist'`:
129129

130130
```js
131131
const chemists = people.filter(person =>
132132
person.profession === 'chemist'
133133
);
134134
```
135135

136-
2. Now **map** over `chemists`:
136+
2. **Petakan** setiap anggota dari seranai `chemists` menggunakan *method* `map()`, yang sudah kita pelajari, menjadi sebuah seranai *node* JSX, `listItems`:
137137

138138
```js {1,13}
139139
const listItems = chemists.map(person =>
@@ -151,12 +151,14 @@ const listItems = chemists.map(person =>
151151
);
152152
```
153153

154-
3. Lastly, **return** the `listItems` from your component:
154+
3. **Kembalikan** `listItems` dari komponen Anda dengan membungkusnya terlebih dahulu dengan elemen `ul`:
155155

156156
```js
157157
return <ul>{listItems}</ul>;
158158
```
159159

160+
Hasil akhirnya seperti berikut:
161+
160162
<Sandpack>
161163

162164
```js App.js
@@ -244,23 +246,23 @@ img { width: 100px; height: 100px; border-radius: 50%; }
244246

245247
<Pitfall>
246248

247-
Arrow functions implicitly return the expression right after `=>`, so you didn't need a `return` statement:
249+
*Arrow function* mengembalikan, secara implisit, pernyataan tepat setelah `=>`, sehingga Anda tidak perlu menulis `return`:
248250

249251
```js
250252
const listItems = chemists.map(person =>
251-
<li>...</li> // Implicit return!
253+
<li>...</li> // Return secara implisit
252254
);
253255
```
254256

255-
However, **you must write `return` explicitly if your `=>` is followed by a `{` curly brace!**
257+
Namun, **Anda harus menulis `return` secara eksplisit jika setelah `=>` terdapat `{`!**
256258

257259
```js
258-
const listItems = chemists.map(person => { // Curly brace
260+
const listItems = chemists.map(person => { // Kurung kurawal
259261
return <li>...</li>;
260262
});
261263
```
262264

263-
Arrow functions containing `=> {` are said to have a ["block body".](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#function_body) They let you write more than a single line of code, but you *have to* write a `return` statement yourself. If you forget it, nothing gets returned!
265+
*Arrow function* yang mengandung `=> {` dianggap memiliki ["badan/isi"](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#function_body). Anda diperbolehkan menulis fungsi yang melebihi satu baris, tetapi Anda **harus menulis `return`**. Jika Anda melupakan ini, fungsi tersebut tidak akan mengembalikan nilai apapun!
264266

265267
</Pitfall>
266268

0 commit comments

Comments
 (0)