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
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`).
125
125
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:
127
127
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'`:
129
129
130
130
```js
131
131
constchemists=people.filter(person=>
132
132
person.profession==='chemist'
133
133
);
134
134
```
135
135
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`:
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!
0 commit comments