Backpack Mistake explainer


#83

Hello guys, I can not edit the right side of the equality. Please, help me. Thank you.

image


#84

Hey @Carlos_Eduardo_Costa,

You don’t need to create the otherBackpack object to solve this puzzle. You may find the puzzle explainer here useful.

Thanks,
H :slight_smile:


#85

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?


#86

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 :slight_smile:


#87

You’re welcome! Actually, now I have solved the code. Thank you for informing.


#88


I got here and now in very confused on what to next I went a practice of this problem but no help


#89

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


#90

I tried this and it worked!

for (var element of otherBackpack.food {
print (element);
}
That really worked!
Cool