Skip to content

Commit 3c4c432

Browse files
authored
Merge pull request #222 from hoangnv170752/master
Functions
2 parents 609db2b + 5c98802 commit 3c4c432

File tree

9 files changed

+162
-162
lines changed

9 files changed

+162
-162
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
No difference.
1+
Không có sự thay đổi nào.

Diff for: 1-js/02-first-steps/15-function-basics/1-if-else-required/task.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 4
22

33
---
44

5-
# Is "else" required?
5+
# "else" có bắt buộc không?
66

7-
The following function returns `true` if the parameter `age` is greater than `18`.
7+
Hàm sau đây sẽ trả về `true` nếu tham số `age` là lớn hơn `18`.
88

9-
Otherwise it asks for a confirmation and returns its result:
9+
Nếu không thì nó sẽ hỏi một câu xác nhận và trả về kết quả của nó:
1010

1111
```js
1212
function checkAge(age) {
@@ -15,13 +15,13 @@ function checkAge(age) {
1515
*!*
1616
} else {
1717
// ...
18-
return confirm('Did parents allow you?');
18+
return confirm('Bố mẹ đã cho phép bạn chưa?');
1919
}
2020
*/!*
2121
}
2222
```
2323

24-
Will the function work differently if `else` is removed?
24+
Hàm sẽ thực hiện khác đi nếu từ `else` bị lược bỏ hay không?
2525

2626
```js
2727
function checkAge(age) {
@@ -30,9 +30,9 @@ function checkAge(age) {
3030
}
3131
*!*
3232
// ...
33-
return confirm('Did parents allow you?');
33+
return confirm('Bố mẹ đã cho phép bạn chưa?');
3434
*/!*
3535
}
3636
```
3737

38-
Is there any difference in the behavior of these two variants?
38+
Có sự khác biệt nào trong hành vi của hai biến thể này không?
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
Using a question mark operator `'?'`:
1+
Sử dụng toán tử dấu chấm hỏi `'?'`:
22

33
```js
44
function checkAge(age) {
5-
return (age > 18) ? true : confirm('Did parents allow you?');
5+
return (age > 18) ? true : confirm('Bố mẹ đã cho phép bạn chưa?');
66
}
77
```
88

9-
Using OR `||` (the shortest variant):
9+
Sử dụng OR `||` (biến thể ngắn nhất):
1010

1111
```js
1212
function checkAge(age) {
13-
return (age > 18) || confirm('Did parents allow you?');
13+
return (age > 18) || confirm('Bố mẹ đã cho phép bạn chưa?');
1414
}
1515
```
1616

17-
Note that the parentheses around `age > 18` are not required here. They exist for better readability.
17+
Lưu ý rằng dấu ngoặc đơn quanh `age > 18` là không bắt buộc. Chúng tồn tại để chúng ta dễ đọc hơn.

Diff for: 1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ importance: 4
22

33
---
44

5-
# Rewrite the function using '?' or '||'
5+
# Viết lại hàm sử dụng '?' hoặc '||'
66

77
The following function returns `true` if the parameter `age` is greater than `18`.
88

Diff for: 1-js/02-first-steps/15-function-basics/3-min/solution.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
A solution using `if`:
1+
Một phương án sử dụng `if`:
22

33
```js
44
function min(a, b) {
@@ -10,12 +10,12 @@ function min(a, b) {
1010
}
1111
```
1212

13-
A solution with a question mark operator `'?'`:
13+
Giải pháp với toán tử `'?'`:
1414

1515
```js
1616
function min(a, b) {
1717
return a < b ? a : b;
1818
}
1919
```
2020

21-
P.S. In the case of an equality `a == b` it does not matter what to return.
21+
Tái bút: Trong trường hợp so sánh bằng nhau `a == b` thì không quan trọng giá trị trả về là gì.

Diff for: 1-js/02-first-steps/15-function-basics/3-min/task.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 1
22

33
---
44

5-
# Function min(a, b)
5+
# Hàm min(a, b)
66

7-
Write a function `min(a,b)` which returns the least of two numbers `a` and `b`.
7+
Viết một hàm `min(a,b)` trả về giá trị nhỏ nhất trong hai số `a` `b`.
88

9-
For instance:
9+
Ví dụ:
1010

1111
```js
1212
min(2, 5) == 2

Diff for: 1-js/02-first-steps/15-function-basics/4-pow/solution.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let x = prompt("x?", '');
1414
let n = prompt("n?", '');
1515

1616
if (n < 1) {
17-
alert(`Power ${n} is not supported, use a positive integer`);
17+
alert(`Số mũ ${n} không được hỗ trợ, hãy dùng một số nguyên dương`);
1818
} else {
1919
alert( pow(x, n) );
2020
}

Diff for: 1-js/02-first-steps/15-function-basics/4-pow/task.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ importance: 4
22

33
---
44

5-
# Function pow(x,n)
5+
# Hàm pow(x,n)
66

7-
Write a function `pow(x,n)` that returns `x` in power `n`. Or, in other words, multiplies `x` by itself `n` times and returns the result.
7+
Viết một hàm `pow(x,n)` trả về biến `x` với số mũ `n`. Hoặc, nói theo cách khác, thì nhân `x` với chính nó `n` lần và trả về kết quả.
88

99
```js
1010
pow(3, 2) = 3 * 3 = 9
1111
pow(3, 3) = 3 * 3 * 3 = 27
1212
pow(1, 100) = 1 * 1 * ...* 1 = 1
1313
```
1414

15-
Create a web-page that prompts for `x` and `n`, and then shows the result of `pow(x,n)`.
15+
Tạo 1 trang web gợi ý cho `x` `n`, và sau đó đưa ra kết quả của `pow(x,n)`.
1616

1717
[demo]
1818

19-
P.S. In this task the function should support only natural values of `n`: integers up from `1`.
19+
Tái bút: Trong nhiệm vụ này, hàm chỉ hỗ trợ các giá trị tự nhiên của `n`: các số nguyên dương lớn hơn hoặc bằng `1`.

0 commit comments

Comments
 (0)