File tree Expand file tree Collapse file tree
1-js/05-data-types/10-destructuring-assignment Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ importance: 5
22
33---
44
5- # Destructuring assignment
5+ # แยกค่าด้วย destructuring assignment
66
7- We have an object:
7+ กำหนดออบเจ็กต์ ( object) ให้ดังนี้ :
88
99``` js
1010let user = {
@@ -13,18 +13,18 @@ let user = {
1313};
1414```
1515
16- Write the destructuring assignment that reads :
16+ เขียน destructuring assignment เพื่ออ่านค่าจากพร็อพเพอร์ตี้ (property) มาใส่ตัวแปร (variable) ตามเงื่อนไขต่อไปนี้ :
1717
18- - ` name ` property into the variable ` name ` .
19- - ` years ` property into the variable ` age ` .
20- - ` isAdmin ` property into the variable ` isAdmin ` (false, if no such property)
18+ - นำค่าของ ` name ` มาใส่ตัวแปร ` name `
19+ - นำค่าของ ` years ` มาใส่ตัวแปร ` age `
20+ - นำค่าของ ` isAdmin ` มาใส่ตัวแปร ` isAdmin ` ถ้าไม่มีพร็อพเพอร์ตี้นี้ ให้ใช้ค่า ` false `
2121
22- Here's an example of the values after your assignment :
22+ เมื่อกำหนดค่าแล้ว ตัวแปรควรมีค่าตามตัวอย่างนี้ :
2323
2424``` js
2525let user = { name: " John" , years: 30 };
2626
27- // your code to the left side :
27+ // เขียนโค้ดของคุณทางซ้ายของเครื่องหมายเท่ากับ :
2828// ... = user
2929
3030alert ( name ); // John
Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ importance: 5
22
33---
44
5- # The maximal salary
5+ # หาคนที่ได้เงินเดือนสูงสุด
66
7- There is a ` salaries ` object :
7+ กำหนดออบเจ็กต์ (object) ` salaries ` ให้ดังนี้ :
88
99``` js
1010let salaries = {
@@ -14,9 +14,9 @@ let salaries = {
1414};
1515```
1616
17- Create the function ` topSalary(salaries) ` that returns the name of the top-paid person.
17+ เขียนฟังก์ชัน ( function) ` topSalary(salaries) ` ที่คืนค่า (return) เป็นชื่อของคนที่ได้เงินเดือนสูงสุด
1818
19- - If ` salaries ` is empty, it should return ` null ` .
20- - If there are multiple top-paid persons, return any of them.
19+ - ถ้า ` salaries ` เป็นออบเจ็กต์ว่าง ให้คืนค่า ` null `
20+ - ถ้ามีหลายคนได้เงินเดือนสูงสุดเท่ากัน ให้คืนชื่อคนใดคนหนึ่งในกลุ่มนั้น
2121
22- P.S. Use ` Object.entries ` and destructuring to iterate over key/value pairs.
22+ ให้ใช้ ` Object.entries ` ร่วมกับ destructuring เพื่อวนอ่านข้อมูลทีละคู่ โดยแต่ละคู่ประกอบด้วยคีย์ ( key) และค่า
You can’t perform that action at this time.
0 commit comments