Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Objects#102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
EpicHigh merged 1 commit intojavascript-tutorial:masterfromkoramit:master
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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 deletions1-js/04-object-basics/01-object/2-hello-object/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletion1-js/04-object-basics/01-object/3-is-empty/solution.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
Just loop over theobjectand `return false`immediately if there's at least one property.
ทดสอบด้วยการวนลูปobjectแล้ว `return false`ทันทีที่พบ propperty อย่างน้อย 1 ตัว
11 changes: 5 additions & 6 deletions1-js/04-object-basics/01-object/3-is-empty/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,19 +2,18 @@ importance: 5

---

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

Write thefunction `isEmpty(obj)`which returns`true`if theobjecthas 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 deletions1-js/04-object-basics/01-object/5-sum-object/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@ importance: 5

---

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

We have anobjectstoring 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 deletions1-js/04-object-basics/01-object/8-multiply-numeric/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,14 +2,14 @@ importance: 3

---

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

Create afunction `multiplyNumeric(obj)`that multiplies all numericpropertyvalues 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

[8]ページ先頭

©2009-2025 Movatter.jp