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: 1-js/02-first-steps/03-strict-mode/article.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,13 +73,13 @@ Jika tidak, cara paling terpercaya ialah memastikan `use strict` adalah menginpu
73
73
74
74
## Selalu "use strict"
75
75
76
-
Kita belum mengcover perbedaan antara mode strict dan mode "default".
76
+
Kita belum mengcover perbedaan antara mode ketat dan mode "default".
77
77
78
-
Di bab berikutnya, seiring kira mempelajari fitur bahasa, kita akan mencatat perbedaan antara mode strict dan default. Untungnya, itu tidak banyak dan membuat hidup kita lebih baik.
78
+
Di bab berikutnya, seiring kira mempelajari fitur bahasa, kita akan mencatat perbedaan antara mode ketat dan default. Untungnya, itu tidak banyak dan membuat hidup kita lebih baik.
79
79
80
80
Untuk sekarang, cukup tahu sampai di sini secara umum:
81
81
82
82
1. Directive `"use strict"` mengganti engine ke mode "modern", changing the behavior of some built-in features. We'll see the details later in the tutorial.
83
-
2. Mode strict aktif dengan menaruh `"use strict"` paling atas dari script atau function. Beberapa fitur bahasa, seperti "classe" dan "module", mengaktifkan mode strict secara otomatis.
84
-
3. Mode strict didukung semua peramban modern.
85
-
4. Kami sarankan selalu mulai script dengan `"use strict"`. Semua contoh di tutorial ini mengasumsikan mode strict kecuali (sangat jarang) dispesifikasi kebalikannya.
83
+
2. Mode ketat aktif dengan menaruh `"use strict"` paling atas dari script atau function. Beberapa fitur bahasa, seperti "classe" dan "module", mengaktifkan mode ketat secara otomatis.
84
+
3. Mode ketat didukung semua peramban modern.
85
+
4. Kami sarankan selalu mulai script dengan `"use strict"`. Semua contoh di tutorial ini mengasumsikan mode ketat kecuali (sangat jarang) dispesifikasi kebalikannya.
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/10-ifelse/article.md
+1-5Lines changed: 1 addition & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,7 @@ Untuk melakukan itu, kita dapat menggunakan pernyataan `if` dan operator kondi
6
6
7
7
## Pernyataan "if"
8
8
9
-
<<<<<<< HEAD
10
-
Pernyataan `if` mengevaluasi suatu kondisi, dan jika hasil kondisi itu benar (`true`),maka pernyataan tersebut akan mengeksekusi kode di dalam blok `if` tersebut.
11
-
=======
12
-
The `if(...)` statement evaluates a condition in parentheses and, if the result is `true`, executes a block of code.
13
-
>>>>>>> 8c30654f694fe8682f5631809980be931ee4ed72
9
+
Pernyataan `if` mengevaluasi suatu kondisi dan, jika hasil kondisi itu `true`, maka blok kode di dalam `if` akan diexekusi.
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/13-switch/2-rewrite-if-switch/solution.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
The first two checks turn into two `case`. The third check is split into two cases:
1
+
Dua cek pertama berubah ke `case`. Cek ketiga dipecah menjadi dua case:
2
2
3
3
```js run
4
4
let a =+prompt('a?', '');
@@ -21,6 +21,6 @@ switch (a) {
21
21
}
22
22
```
23
23
24
-
Please note: the `break`at the bottom is not required. But we put it to make the code future-proof.
24
+
Tolong ingat: `break`di paling bawah tidak wajib. Tapi kita taruh itu supaya kodenya future-proof.
25
25
26
-
In the future, there is a chance that we'd want to add one more `case`, for example `case 4`. And if we forget to add a break before it, at the end of `case 3`, there will be an error. So that's a kind of self-insurance.
26
+
Di masa depan, ada kans bahwa kita ingin menambah `case` lebih, misalnya `case 4`. Dan jika kita lupa menambah break sebelum itu, di akhir `case 3`, akan ada error. Jadi itu lebih ke semacam asuransi diri.
It gives a more descriptive way to compare a value with multiple variants.
5
+
Ia memberi cara lebih deskriptif untuk membandingkan nilai dengan varian ganda.
6
6
7
-
## The syntax
7
+
## Syntax
8
8
9
-
The `switch`has one or more `case`blocks and an optional default.
9
+
`switch`punya satu atau lebih blok `case`dan satu default opsional.
10
10
11
-
It looks like this:
11
+
Rupanya seperti ini:
12
12
13
13
```js no-beautify
14
14
switch(x) {
@@ -26,13 +26,13 @@ switch(x) {
26
26
}
27
27
```
28
28
29
-
-The value of `x`is checked for a strict equality to the value from the first `case`(that is, `value1`) then to the second (`value2`) and so on.
30
-
-If the equality is found, `switch`starts to execute the code starting from the corresponding `case`, until the nearest`break`(or until the end of`switch`).
31
-
-If no case is matched then the`default`code is executed (if it exists).
29
+
-Nilai `x`dicek ekaulitasnya secara ketat dengan nilaid dari `case`pertama (yaitu, `value1`) lalu ke kedua (`value2`) dan seterusnya.
30
+
-Jika ekualitas ditemukan, `switch`mulai mengexekusi kode mulai dari `case` yang berkorespondensi, hingga`break`terdekat (atau hingga akhir`switch`).
31
+
-Jika tak ada case yang cocok maka kode`default`diexekusi (jika ada).
32
32
33
-
## An example
33
+
## Contoh
34
34
35
-
An example of `switch` (the executed code is highlighted):
35
+
Contoh `switch` (kode yang diexekusi dihighlight):
36
36
37
37
```js run
38
38
let a =2+2;
@@ -54,13 +54,13 @@ switch (a) {
54
54
}
55
55
```
56
56
57
-
Here the`switch`starts to compare `a`from the first `case`variant that is`3`. The match fails.
57
+
Di sini`switch`mulai membandingkan `a`dari varian `case`pertama yang bernilai`3`. Kecocokan gagal.
58
58
59
-
Then`4`. That's a match, so the execution starts from `case 4`until the nearest `break`.
59
+
Lalu`4`. Ada kecocokan, jadi exekusi mulai dari `case 4`hingga `break` terdekat.
60
60
61
-
**If there is no `break`then the execution continues with the next `case`without any checks.**
61
+
**Jika tak ada `break`maka exekusi lanjut dengan `case`berikutnya tanpa pengecekan.**
62
62
63
-
An example without`break`:
63
+
Contoh tanpa`break`:
64
64
65
65
```js run
66
66
let a =2+2;
@@ -79,18 +79,18 @@ switch (a) {
79
79
}
80
80
```
81
81
82
-
In the example above we'll see sequential execution of three `alert`s:
82
+
Di contoh di atas kita akan lihat exekusi sekuensial dari tiga `alert`:
83
83
84
84
```js
85
85
alert( 'Exactly!' );
86
86
alert( 'Too big' );
87
87
alert( "I don't know such values" );
88
88
```
89
89
90
-
````smart header="Any expression can be a`switch/case` argument"
91
-
Both`switch`and`case`allow arbitrary expressions.
90
+
````smart header="Expresi apapun bisa berupa argumen`switch/case`"
Here `+a`gives`1`, that's compared with`b + 1`in`case`, and the corresponding code is executed.
110
+
Di sini `+a`memberikan`1`, yang dibandingkan dengan`b + 1`ndalam`case`, and the corresponding code is executed.
111
111
````
112
112
113
-
## Grouping of "case"
113
+
## Pengelompokan "case"
114
114
115
-
Several variants of `case` which share the same code can be grouped.
115
+
Beberapa varian `case` yang berbagi kode yang sama bisa dikelompokkan.
116
116
117
-
For example, if we want the same code to run for `case 3` and `case 5`:
117
+
Misalnya, jika kita ingin kode yang sama berjalan untuk `case 3` dan `case 5`:
118
118
119
119
```js run no-beautify
120
120
let a = 2 + 2;
@@ -137,15 +137,15 @@ switch (a) {
137
137
}
138
138
```
139
139
140
-
Now both `3` and `5` show the same message.
140
+
Sekarang baik `3` maupun `5` menampilkan pesan yang sama.
141
141
142
-
The ability to "group" cases is a side-effect of how `switch/case` works without `break`. Here the execution of `case 3` starts from the line `(*)` and goes through `case 5`, because there's no `break`.
142
+
Kemampuan "mengelompokkan" case adalah efek samping dari bagaimana `switch/case` bekerja tanpa `break`. Di sini exekusi dari `case 3` mulai dari baris `(*)` dan tembus ke `case 5`, karena tidak ada `break`.
143
143
144
-
## Type matters
144
+
## Tipe berpengaruh
145
145
146
-
Let's emphasize that the equality check is always strict. The values must be of the same type to match.
146
+
Mari kita tekankan bahwa pengecekan ekualitas selalu ketat. Nilainya harus bertipe sama supaya cocok.
147
147
148
-
For example, let's consider the code:
148
+
Misalnya, mari kita pertimbangkan kode ini:
149
149
150
150
```js run
151
151
let arg = prompt("Enter a value?");
@@ -167,6 +167,6 @@ switch (arg) {
167
167
}
168
168
```
169
169
170
-
1. For `0`, `1`, the first `alert` runs.
171
-
2. For `2` the second `alert` runs.
172
-
3. But for `3`, the result of the `prompt` is a string `"3"`, which is not strictly equal `===` to the number `3`. So we've got a dead code in `case 3`! The `default` variant will execute.
170
+
1. Untuk `0`, `1`, `alert` pertama berjalan.
171
+
2. Untuk `2` `alert` kedua berjalan.
172
+
3. Tapi untuk `3`, hasil dari `prompt` ialah string `"3"`, yang berbeda secara ketat `===` dengan angka `3`. Jadi kita punya kode mati di `case 3`! Varian `default` akan diexekusi.
0 commit comments