Hello guys, I can not edit the right side of the equality. Please, help me. Thank you.
Backpack Mistake explainer
You don’t need to create the otherBackpack
object to solve this puzzle. You may find the puzzle explainer here useful.
Thanks,
H
var Hunger = otherBackpack.food
When I am using this code, it is asking me to remove the 2nd variable declaration outside the for loop,even there is nothing outside the for loop. Can I get some help?
Hey @CMPTR,
Thanks for flagging this! The wording of that hint should let you know that you don’t need to create two variables to solve this puzzle (the only one you need is the looping variable: for (var element .... )
). We’re working on updating this hint!
Thanks again for pointing this out,
H
If you scroll up to the 1st post here, you can take a look at what the otherBackpack
actually looks like:
var otherBackpack = {
food: ['crackers', 'chocolate', 'raisins'],
equipment: ['map', 'rope', 'compass'],
clothing: ['hat', 'umbrella', 'boots']
};
It’s an object with 3 properties: food
, equipment
, and clothing
. Each of those properties is storing an array. Since you want to print out all the food in the backpack, you want to loop through the otherBackpack.food
which is the "food property of the otherBackpack
".
Inside the loop, you want to print()
the element
. The element
will store each food item as it loops through the otherBackpack.food
array.
–Frankie
I tried this and it worked!
for (var element of otherBackpack.food {
print (element);
}
That really worked!
Cool