Pack Your Bag explainer


#1

The aim of this puzzle: To create a variable called myBackpack and assign it an object {} to hold. Inside the object there should be three properties: food (with the value 'bananas'), equipment (with the value 'map') and clothing (with the value 'hat'). The final step is to print out the value held by the food property inside the myBackpack object.
Review concepts: The achievements ‘Created a Variable’ and ‘Accessed a Property’s Value’ unlock the ability to complete this puzzle.
Review puzzles: Try taking another a look at the puzzles ‘This is Your Year’ (variable creation), ‘Custom Colors’ and ‘Make a Name for Yourself’ to get an idea of how to create an object, add properties (and property values) to an object and then print out a property’s value using print().
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()


#2

I have no idea why I cannot move forward. It appears to me that I have achieved the goal of the lesson but nothing happens. The program does not move forward. I have signed out and back in. I rerun the code and get the correct results again. After the correct results are display in the results box nothing happens?


Backpack newbie issue
#3

I am having the same issue.


#4

Hi @TomLarryJr,

Could you share a screenshot of your code so I can have a look? I might be able to spot if there is an issue on our side, or a small element in your code that needs to be changed.

Thanks!
Heather :slight_smile:


#5

Hi @MaxH,

Same question! Could you share a screenshot of your code so I can have a look and hopefully figure out what’s blocking you?

Thanks,
Heather :slight_smile:


#6

I got help on. The peoblem was that i made an extra variable for Mybackpack.


#7

Great to hear you got help and were able to solve this puzzle!


#8

Hello. I cannot figure this one out. Please help. The instructions and other notes aren’t enough i am missing something critical here.


#9

Hey @Robert_Hise,

This is a tricky puzzle! The aim is to create a ‘backpack’ which is an object. You may want to look at the lesson ‘Make a Name for Yourself’ to refresh your memory on how objects are structured.

The object should be stored in a variable called myBackpack, and have three properties: food, equipment and clothing. Each of the properties should hold 'bananas', 'map' and 'hat' respectively.

Once the object is created, the food property should be printed out using print(myBackpack.food).

If you’re still having trouble, I’d be more than happy to look at a screenshot of your code and see if I can spot where the issue is.

Thanks,
H :slight_smile:


#10

I figured it out right after I messaged you. I guess I needed to take a break and come back to it. I appreciate the help.


#11

Sweet! Glad you were able to figure it out :slight_smile:


#12

Having trouble here. I know it needs to say print(myBackpack.food), but the code editor won’t let me do that. As soon as I hit myBackpack, it closes the brackets and there’s no way to manually edit it. So I’m stuck.


#13

@TimDS7,

Are you able to tap on myBackpack inside print(myBackpack) then tap on the .food key? You may have to scroll your keyboard to the right to see the .food key.

Let me know if this doesn’t work!
H :slight_smile:


#14

Yes, that worked. Did you change something? I tried everything for 10 mins before, without success.
Thanks anyway… moving on…


#16

Finally I completed this puzzle after trying to figure out the right codes for half an hour very nice puzzle


#17

Whats the problem here


#18

Can you help?


#19

Solution:


#20

I’m stuck too. I reviewed Making a Name for Yourself, and I just don’t know what I did wrong. I’m sad and frustrated.


#21


This is the code that got me past this one