Skip to content

Commit 599fabd

Browse files
authored
Merge branch 'master' into master
2 parents 9cc8ed5 + 53b6d7f commit 599fabd

File tree

95 files changed

+1521
-992
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1521
-992
lines changed

1-js/03-code-quality/05-testing-mocha/article.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ Kita bisa pilih salah satu cara mengorganisasikan tes di sini:
159159
assert.equal(pow(2, 3), 8);
160160
});
161161
162-
it("3 raised to power 3 is 27", function() {
163-
assert.equal(pow(3, 3), 27);
162+
it("3 raised to power 4 is 81", function() {
163+
assert.equal(pow(3, 4), 81);
164164
});
165165
166166
});
@@ -182,7 +182,11 @@ Hasilnya:
182182

183183
[iframe height=250 src="pow-2" edit border="1"]
184184

185+
<<<<<<< HEAD
185186
Seperti yang kita harapkan, tes kedua gagal. Jelas, fungsi kita selalu mengembalikan `8`, sedangkan `assert` mengharapkan `27`.
187+
=======
188+
As we could expect, the second test failed. Sure, our function always returns `8`, while the `assert` expects `81`.
189+
>>>>>>> e92bb83e995dfea982dcdc5065036646bfca13f0
186190

187191
## Mengimprov implementasi
188192

1-js/03-code-quality/05-testing-mocha/pow-2.view/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ describe("pow", function() {
44
assert.equal(pow(2, 3), 8);
55
});
66

7-
it("3 raised to power 3 is 27", function() {
8-
assert.equal(pow(3, 3), 27);
7+
it("3 raised to power 4 is 81", function() {
8+
assert.equal(pow(3, 4), 81);
99
});
1010

1111
});

1-js/05-data-types/01-primitives-methods/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Let's look at the key distinctions between primitives and objects.
77
A primitive
88

99
- Is a value of a primitive type.
10-
- There are 6 primitive types: `string`, `number`, `boolean`, `symbol`, `null` and `undefined`.
10+
- There are 7 primitive types: `string`, `number`, `bigint`, `boolean`, `symbol`, `null` and `undefined`.
1111

1212
An object
1313

1-js/05-data-types/02-number/1-sum-interface/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ let b = +prompt("The second number?", "");
77
alert( a + b );
88
```
99

10-
Note the unary plus `+` before `prompt`. It immediately converts the value to a number.
10+
Catatan bahwa unary plus `+` sebelum `prompt`. Segera mengkonversi nilai ke angka.
1111

12-
Otherwise, `a` and `b` would be string their sum would be their concatenation, that is: `"1" + "2" = "12"`.
12+
Jika tidak, `a` dan `b` akan menjadi string jumlah mereka akan menjadi gabungan mereka, yaitu: `"1" + "2" = "12"`.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
importance: 5
1+
nilai penting: 5
22

33
---
44

5-
# Sum numbers from the visitor
5+
# Jumlahkan angka dari pengunjung
66

7-
Create a script that prompts the visitor to enter two numbers and then shows their sum.
7+
Buat skrip yang meminta pengunjung untuk memasukkan dua angka dan kemudian menunjukkan jumlah mereka.
88

99
[demo]
1010

11-
P.S. There is a gotcha with types.
11+
N.B. Ada gotcha dengan tipe.

1-js/05-data-types/02-number/2-why-rounded-down/solution.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
Internally the decimal fraction `6.35` is an endless binary. As always in such cases, it is stored with a precision loss.
1+
Secara internal pecahan desimal `6.35` adalah sebuah biner tanpa akhir. Seperti biasa dalam kasus seperti ini, disimpan dengan kehilangan presisi.
22

3-
Let's see:
3+
Ayo lihat:
44

55
```js run
66
alert( 6.35.toFixed(20) ); // 6.34999999999999964473
77
```
88

9-
The precision loss can cause both increase and decrease of a number. In this particular case the number becomes a tiny bit less, that's why it rounded down.
9+
Kehilangan presisi dapat menyebabkan peningkatan dan penurunan angka. Dalam kasus khusus ini jumlahnya menjadi sedikit lebih sedikit, itu sebabnya dibulatkan.
1010

11-
And what's for `1.35`?
11+
Dan apa untuk `1.35`?
1212

1313
```js run
1414
alert( 1.35.toFixed(20) ); // 1.35000000000000008882
1515
```
1616

17-
Here the precision loss made the number a little bit greater, so it rounded up.
17+
Di sini kehilangan presisi membuat jumlahnya sedikit lebih besar, jadi itu dibulatkan.
1818

19-
**How can we fix the problem with `6.35` if we want it to be rounded the right way?**
19+
**Bagaimana kita dapat memperbaiki masalah dengan `6.35` jika kita ingin itu dibulatkan dengan cara yang benar?**
2020

21-
We should bring it closer to an integer prior to rounding:
21+
Kita harus membawanya lebih dekat ke integer sebelum pembulatan:
2222

2323
```js run
2424
alert( (6.35 * 10).toFixed(20) ); // 63.50000000000000000000
2525
```
2626

27-
Note that `63.5` has no precision loss at all. That's because the decimal part `0.5` is actually `1/2`. Fractions divided by powers of `2` are exactly represented in the binary system, now we can round it:
27+
Perhatikan bahwa `63.5` tidak memiliki kehilangan presisi sama sekali. Itu karena bagian desimal `0,5` sebenarnya` 1 / 2`. Pecahan yang dibagi oleh kekuatan `2` persis diwakili dalam sistem biner, sekarang kita dapat membulatkannya:
2828

2929

3030
```js run
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
importance: 4
1+
nilai penting: 4
22

33
---
44

5-
# Why 6.35.toFixed(1) == 6.3?
5+
# Kenapa 6.35.toFixed(1) == 6.3?
66

7-
According to the documentation `Math.round` and `toFixed` both round to the nearest number: `0..4` lead down while `5..9` lead up.
7+
Berdasarkan dokumentasi `Math.round` dan `toFixed` keduanya membulatkan ke angka terdekat: `0..4` turun sementara `5..9` naik.
88

9-
For instance:
9+
Contohnya:
1010

1111
```js run
1212
alert( 1.35.toFixed(1) ); // 1.4
1313
```
1414

15-
In the similar example below, why is `6.35` rounded to `6.3`, not `6.4`?
15+
Dalam contoh serupa di bawah ini, mengapa `6.35` dibulatkan menjadi `6.3`, dan tidak `6.4`?
1616

1717
```js run
1818
alert( 6.35.toFixed(1) ); // 6.3
1919
```
2020

21-
How to round `6.35` the right way?
21+
Bagaimana untuk membulatkan `6.35` dengan benar?
2222

1-js/05-data-types/02-number/3-repeat-until-number/solution.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ function readNumber() {
1515
alert(`Read: ${readNumber()}`);
1616
```
1717

18-
The solution is a little bit more intricate that it could be because we need to handle `null`/empty lines.
18+
Solusinya sedikit lebih rumit dari itu karena kita perlu menangani `null`/baris kosong.
1919

20-
So we actually accept the input until it is a "regular number". Both `null` (cancel) and empty line also fit that condition, because in numeric form they are `0`.
20+
Jadi, kita benar-benar menerima input hingga ini merupakan "angka reguler". Baik `null` (cancel) maupun baris kosong juga cocok dengan kondisi itu, karena dalam bentuk numerik mereka adalah` 0`.
2121

22-
After we stopped, we need to treat `null` and empty line specially (return `null`), because converting them to a number would return `0`.
22+
Setelah kita berhenti, kita perlu memperlakukan `null` dan khususnya baris kosong (mengembalikan `null`), karena mengonversinya menjadi angka akan mengembalikan `0`.
2323

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
importance: 5
1+
nilai penting: 5
22

33
---
44

5-
# Repeat until the input is a number
5+
# Ulangi sampai masukan adalah sebuah angka
66

7-
Create a function `readNumber` which prompts for a number until the visitor enters a valid numeric value.
7+
Buatlah sebuah fungsi `readNumber` yang meminta (prompts) nomor hingga pengunjung memasukkan nilai numerik yang valid.
88

9-
The resulting value must be returned as a number.
9+
Nilai yang dihasilkan harus dikembalikan sebagai angka.
1010

11-
The visitor can also stop the process by entering an empty line or pressing "CANCEL". In that case, the function should return `null`.
11+
Pengunjung juga dapat menghentikan proses dengan memasukkan baris kosong atau menekan "BATAL". Dalam hal ini, fungsi tersebut harus mengembalikan `null`.
1212

1313
[demo]
1414

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
That's because `i` would never equal `10`.
1+
Itu karena `i` tidak akan pernah sebanding dengan `10`.
22

3-
Run it to see the *real* values of `i`:
3+
Jalankan ini untuk melihat nilai *real* dari `i`:
44

55
```js run
66
let i = 0;
@@ -10,8 +10,8 @@ while (i < 11) {
1010
}
1111
```
1212

13-
None of them is exactly `10`.
13+
Tidak satu pun dari mereka yang benar-benar `10`.
1414

15-
Such things happen because of the precision losses when adding fractions like `0.2`.
15+
Hal-hal seperti itu terjadi karena kehilangan presisi ketika menambahkan pecahan seperti `0,2`.
1616

17-
Conclusion: evade equality checks when working with decimal fractions.
17+
Kesimpulan: menghindari pemeriksaan kesetaraan saat bekerja dengan pecahan desimal.

1-js/05-data-types/02-number/4-endless-loop-error/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
importance: 4
1+
nilai penting: 4
22

33
---
44

5-
# An occasional infinite loop
5+
# Lingkaran tak terbatas tak berkala
66

7-
This loop is infinite. It never ends. Why?
7+
Loop ini tidak terbatas. Tidak pernah berakhir. Mengapa?
88

99
```js
1010
let i = 0;

1-js/05-data-types/02-number/8-random-min-max/solution.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
We need to "map" all values from the interval 0..1 into values from `min` to `max`.
1+
Kita perlu "memetakan" semua nilai dari interval 0..1 ke dalam nilai dari `min` ke` max`.
22

3-
That can be done in two stages:
3+
Itu bisa dilakukan dalam dua tahap:
44

5-
1. If we multiply a random number from 0..1 by `max-min`, then the interval of possible values increases `0..1` to `0..max-min`.
6-
2. Now if we add `min`, the possible interval becomes from `min` to `max`.
5+
1. Jika kita mengalikan angka acak dari 0..1 dengan `max-min`, maka interval nilai yang mungkin meningkat` 0..1` ke `0..max-min`.
6+
2. Sekarang jika kita menambahkan `min`, interval yang mungkin menjadi dari` min` ke `max`.
77

8-
The function:
8+
Fungsi:
99

1010
```js run
1111
function random(min, max) {

1-js/05-data-types/02-number/8-random-min-max/task.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
importance: 2
1+
nilai penting: 2
22

33
---
44

5-
# A random number from min to max
5+
# Sebuah angka acak dari min ke max
66

7-
The built-in function `Math.random()` creates a random value from `0` to `1` (not including `1`).
7+
Fungsi bawaan `Math.random()` membuat sebuah angka acak dari `0` ke `1` (tidak termasuk `1`).
88

9-
Write the function `random(min, max)` to generate a random floating-point number from `min` to `max` (not including `max`).
9+
Tulis fungsi `random(min, max)` untuk menghasilkan angka floating-point acak dari `min` ke` max` (tidak termasuk `max`).
1010

11-
Examples of its work:
11+
Contoh kerjanya:
1212

1313
```js
1414
alert( random(1, 5) ); // 1.2345623452
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
importance: 2
1+
nilai penting: 2
22

33
---
44

5-
# A random integer from min to max
5+
# Sebuah integer acak dari min ke max
66

7-
Create a function `randomInteger(min, max)` that generates a random *integer* number from `min` to `max` including both `min` and `max` as possible values.
7+
Buatlah sebuah fungsi `randomInteger(min, max)` yang menghasilkan angka *integer* acak dari `min` ke `max` termasuk keduanya `min` dan `max` sebagai nilai yang mungkin.
88

9-
Any number from the interval `min..max` must appear with the same probability.
9+
Angka apa pun dari interval `min..max` harus muncul dengan probabilitas yang sama.
1010

1111

12-
Examples of its work:
12+
Contoh kerjanya:
1313

1414
```js
1515
alert( randomInteger(1, 5) ); // 1
1616
alert( randomInteger(1, 5) ); // 3
1717
alert( randomInteger(1, 5) ); // 5
1818
```
1919

20-
You can use the solution of the [previous task](info:task/random-min-max) as the base.
20+
Anda dapat menggunakan solusi dari [tugas sebelumnya](info:task/random-min-max) sebagai basis.

0 commit comments

Comments
 (0)