Backpack Mistake explainer


The aim of this puzzle: To create a for…of loop that loops through and prints out all the items inside the array of the food property of the object otherBackpack.
Review concepts: The achievements ‘Accessed a Property’s Value’ and ‘Used a For Loop’ unlock the ability to complete this puzzle.
Review puzzles: Try taking another a look at the puzzles ‘String Looping’ (for…of loop with strings) ‘Longer Rainbow’ (for…of loop with an array) and ‘Make a Name for Yourself’ (accessing an objects property).
Sample code solution:
(Tap below to reveal)

Since this is part of the final topic of the fundamentals course and it is testing your knowledge, there is no sample solution code.

JavaScript Concepts: Object Expressions, Member Expressions, Calling Functions
Grasshopper Concepts: print()

Additional Code (hidden code that runs before the puzzle’s code):

var otherBackpack = {
    food: ['crackers', 'chocolate', 'raisins'],
    equipment: ['map', 'rope', 'compass'],
    clothing: ['hat', 'umbrella', 'boots']

Further. Conceptual doubts
Problem with Backpack mistake!
Image Decoder explainer

I am so confused on this puzzle. I try to add ‘item’ but it won’t let my keyboard type, nor does it let me draw a new line nor do anything like it suggests to review from the other puzzles. Very frustrating.


I am also verry confused


Hey @emjones214,

This is one of the last few puzzles of the fundamentals course — meaning they are particularly tricky, so don’t feel bad about struggling with it!

In this puzzle you won’t need newLine(). newLine() is used to move the ‘grasshopper’ to a new line when it is drawing boxes, however it isn’t needed when printing out strings. Longer Rainbow is a review puzzle because it shows you how to loop through an array; however Longer Rainbow is drawing out boxes rather than printing out statements. You may also find the puzzle String Looping useful to see how letters can be printed out on new lines using a loop.

You can rename your looping variable to use item if you want, but you can also keep it as the default element (when the for loop is created). The word item used in this explainer is just to reference the need to go through every element/item/‘thing’ in the array, not that the looping variable needs to be called item. If you do want to change it from for (var element of ... ) to for (var item of...) you can do this by double tapping on the element name in the code.

To solve this puzzle I’d suggest first creating a for loop, then think of how to access the food property inside otherBackpack, then inside the block of the for loop {} add a print function that prints out the looping variable (i.e. element or item if you’ve changed it).

Hopefully this helps a little!
H :slight_smile:


I kind of found out how to get it just cant make it print just one item even looking at others


Hey @Tasnas123,

Sorry you’ve got stuck :stuck_out_tongue: — could you take a screenshot of the code you are trying and I should be able to provide some pointers.

H :slight_smile:


Hey @Epicturtle,

Firstly — great username.

Secondly, would you be able to take a screenshot of the code you are trying for this puzzle and I’ll see if I’m able to spot what’s going wrong?

H :slight_smile:


I too am very confused. I got to this point in 2 evenings, but now feel like I didn’t learn anything. Maybe I just don’t learn well with the method of this app. You just never know if the variable is already defined or if you need to do that step also.


Hey @Higgins,

Don’t feel bad for getting stuck — these puzzles are the most difficult in the fundamentals course. If you’ve been able to get this far you’ve definitely been learning, it’s likely that the concepts on this puzzle are just not quite clear enough.

You also make a good point about variables. Most of the time you have to define the variable (or it’s already defined in the starter code). In a couple puzzles, including this one, there is a variable that is already defined and ‘hidden’. In this case the variable otherBackpack is already defined an hidden, you don’t need to create it again. However, you know the structure of it — it has the same structure as the variable you created previous myBackpack. That is, arrays inside an object.

In this puzzle you just need to add a for loop. The loop needs to go through the array stored inside the food property of otherBackpack. From the puzzle, Get More Supplies, you know how to access an objects property, for example So the first line of code will look something like for (var element of

The final step is to print out each item/element of the array.

Hopefully this helps a little!
H :slight_smile:


Thank you for the clarification. I was able to quickly solve this puzzle with you help.


thanks but I figured it out. I was just being stupid


I also feel like I got to this point and realized I don’t understand anything g about what I’m doing. I feel like I should start over.


Hey @Uuurrrgh

I definitely know that feeling.

If you feel like it’s be useful to go through the course again you can do this yourself (just tap back into any puzzle or question).

To solve this puzzle you need to do three things:

  • Create a for…of loop
  • Have the for…of loop go through the array stored inside the food property, inside of the otherBackpack object. To do this you have to access an object’s property using
  • Print out each element from the food property’s array. This will be one line of code using print() and referencing the variable that’s looping through

Hopefully this helps a little!
H :slight_smile:


Why does it keep hiding code from us. I’m a learner that needs to see everything that is going on. Just having me follow directions doesn’t teach me anything. I need to know why I’m doing something.

I tried to build the variable of otherBackpack, but turns out it’s already an entity that is just hidden for no reason. Just show me what I’m editing. Please.


Hi @Dylan_Harper,

Great feedback and something we’re working on prioritizing!

We hide some of the code to not make the environment overwhelming (since a phone screen has limited real estate), and allow users to focus on the elements of the code they need to create/change.

However, I completely agree with you that this can be confusing — we are working on addressing this, so thanks for the feedback!

H :slight_smile:

Image Decoder explainer

Cool, cool, thanks for the info. For the time being it’d help me (at least) if there was a heads up on ones that had hidden code.


Yes , the fact that the variables are already defined but hidden should more clear, this what had me confused


@Nardo_Bezemer — Noted! Thanks for sharing your feedback :slight_smile:


Solution for Backup mistake