Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions 1-js/04-object-basics/01-object/2-hello-object/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ importance: 5

# Hello, object

Write the code, one line for each action:

1. Create an empty object `user`.
2. Add the property `name` with the value `John`.
3. Add the property `surname` with the value `Smith`.
4. Change the value of the `name` to `Pete`.
5. Remove the property `name` from the object.
ให้เขียนโค้ดเพื่อทำงานตามข้างล่างนี้ โดยแต่ละข้อให้เขียนได้เพียง 1 บรรทัดเท่านั้น:

1. สรา้ง object ชื่อว่า `user`
2. เพิ่ม property `name` มี value เป็น `John`
3. เพิ่ม property `surname` มี value เป็น `Smith`
4. เปลี่ยนค่าของ `name` เป็น `Pete`
5. ลบ property `name` ออกจาก object
2 changes: 1 addition & 1 deletion 1-js/04-object-basics/01-object/3-is-empty/solution.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Just loop over the object and `return false` immediately if there's at least one property.
ทดสอบด้วยการวนลูป object แล้ว `return false` ทันทีที่พบ propperty อย่างน้อย 1 ตัว
11 changes: 5 additions & 6 deletions 1-js/04-object-basics/01-object/3-is-empty/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ importance: 5

---

# Check for emptiness
# ตรวจสอบ object ว่าง

Write the function `isEmpty(obj)` which returns `true` if the object has no properties, `false` otherwise.
เขียน function `isEmpty(obj)` ที่จะตอบกลับ `true` เมื่อ object ไม่มี property ใดๆ เลย ตอบกลับ `false` หากเป็นอย่างอื่น

Should work like that:
ควรทำงานได้ทำนองนี้:

```js
let schedule = {};

alert( isEmpty(schedule) ); // true
alert( isEmpty(schedule) ); // ตอบ true

schedule["8:30"] = "get up";

alert( isEmpty(schedule) ); // false
alert( isEmpty(schedule) ); // ตอบ false
```

8 changes: 4 additions & 4 deletions 1-js/04-object-basics/01-object/5-sum-object/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ importance: 5

---

# Sum object properties
# หาผลรวมของ property ใน object

We have an object storing salaries of our team:
เรามี object เก็บค่าเงินเดือนของสมาชิกในทีมดังนี้:

```js
let salaries = {
Expand All @@ -14,6 +14,6 @@ let salaries = {
}
```

Write the code to sum all salaries and store in the variable `sum`. Should be `390` in the example above.
เขียนโค้ดเพื่อหาผลรวมโดยเก็บไว้ในตัวแปร `sum` โดยจากข้อมูลข้างบนต้องได้ค่า 390

If `salaries` is empty, then the result must be `0`.
ถ้า `salaries` เป็น object ว่างให้ตอบ `0`
16 changes: 7 additions & 9 deletions 1-js/04-object-basics/01-object/8-multiply-numeric/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ importance: 3

---

# Multiply numeric property values by 2
# คูณค่าของ property ทุกตัวที่มี value ป็นค่าเชิงตัวเลขด้วย 2

Create a function `multiplyNumeric(obj)` that multiplies all numeric property values of `obj` by `2`.
สร้าง function `multiplyNumeric(obj)` ที่จะทำการคูณค่าของ property ทุกตัวใน `obj` ที่มี value เป็นค่าเชิงตัวเลขด้วย `2`

For instance:
ตัวอย่างเช่น:

```js
// before the call
// ก่อนเรียกใช้ function
let menu = {
width: 200,
height: 300,
Expand All @@ -18,16 +18,14 @@ let menu = {

multiplyNumeric(menu);

// after the call
// หลังเรียกใช้ function
menu = {
width: 400,
height: 600,
title: "My menu"
};
```

Please note that `multiplyNumeric` does not need to return anything. It should modify the object in-place.

P.S. Use `typeof` to check for a number here.

โปรดทราบว่า `multiplyNumeric` ไม่จำเป็นต้องตอบกลับ แต่ทำการเปลี่ยนค่าของ object

ป.ล. ใช้ `typeof` เพื่อทดสอบว่าเป็นค่าเชิงตัวเลข
Loading