Try as I might after RAS I can’t seem to make hide nor hair of this. Can anyone point me in the right direction?
Your code so far
let foods = {
apples: 25,
oranges: 32,
plums: 28,
bananas: 13,
grapes: 35,
strawberries: 27
};
// do not change code above this line
// change code below this line
let inventory = foods[selectedFood];
return foods(scannedItem);
}
// change code below this line to test different cases:
console.log(checkInventory("apples"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.
Ah man, you’re there! The only problem is that you used the wrong parentheses: the bracket notation is the one used in the example ( the one you reported above your return statement which you should get rid of ) and that’s the syntax to dynamically check properties of an object ( e.g. using a variable with different values to read different properties )
Yes yes, the second line is the almost correct one ^^
The first line is an example you have to get rid of, just watch how it use the parenthesis before to delete it and reply to syntax in your line^^
EDIT:
Ah, just clicked the link: read the comment @JM-Mendez put into his example
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 scannedItem ? foods[scannedItem]:undefined;
}
// change code below this line to test different cases:
console.log(checkInventory("apples"));