2018-10-12 16:35:31 -04:00
|
|
|
---
|
|
|
|
title: Access Property Names with Bracket Notation
|
|
|
|
localeTitle: الوصول إلى خاصية الأسماء مع تدرج قوس
|
|
|
|
---
|
|
|
|
## الوصول إلى خاصية الأسماء مع تدرج قوس
|
|
|
|
|
|
|
|
طريقة:
|
|
|
|
|
|
|
|
* باستخدام `checkInventory()` قوس ببساطة اكتب بيان الإرجاع في الدالة `checkInventory()` .
|
|
|
|
* كتلة التعليمات البرمجية التالية يوضح بناء الجملة المطلوب.
|
|
|
|
|
|
|
|
## مثال:
|
|
|
|
|
2019-06-20 14:05:02 -07:00
|
|
|
```javascript
|
|
|
|
let juice = {
|
|
|
|
apple: 1.15,
|
|
|
|
orange: 1.45
|
|
|
|
};
|
|
|
|
function checkInventory(scannedItem) {
|
|
|
|
return juice[scannedItem];
|
|
|
|
}
|
|
|
|
```
|
2018-10-12 16:35:31 -04:00
|
|
|
|
|
|
|
## حل:
|
|
|
|
|
2019-06-20 14:05:02 -07:00
|
|
|
```javascript
|
|
|
|
let foods = {
|
|
|
|
apples: 25,
|
|
|
|
oranges: 32,
|
|
|
|
plums: 28,
|
|
|
|
bananas: 13,
|
|
|
|
grapes: 35,
|
|
|
|
strawberries: 27
|
|
|
|
};
|
|
|
|
// do not change code above this line
|
|
|
|
|
|
|
|
function checkInventory(scannedItem) {
|
|
|
|
// change code below this line
|
|
|
|
return foods[scannedItem];
|
|
|
|
}
|
|
|
|
|
|
|
|
// change code below this line to test different cases:
|
|
|
|
console.log(checkInventory("apples"));
|
|
|
|
```
|