Pack Your Bag explainer


#42

@Dak_Amum Looks like you’ve accidentally inserted a string rather than the variable and property on the last line of your code. A string is surrounded by quotes, so instead of print (‘myBackpack.Food’); we want print (myBackpack.food); without the single quotation marks. You should be able to delete the string and then look for the myBackpack variable as it’s own button. Then, with myBackpack still highlighted, look for the .food property button to add it onto the end of your variable.


#43

Great! Thanks RetroJLO.


#44

Please kindly advice


#45

I was able to complete the puzzle, but the accepted solution code is incorrect. There should not be a comma after the last object property. Perhaps the app should add a comma to the preceding property only when adding a new property.


#46

@Jeff_Geller That is correct but since the learning app has generic syntax it is showing that last comma. It bugged me as well but I dismissed it as being a starting point. But your right when we try this in real life errors will happen and confuse users. Perhaps this can be fixed @grasshopper, @Grasshopper_Heather?


#47

Hey @Jeff_Geller and @Ahsen,

We have the extra field for Arrays and Objects to make it easy for users to tap to add new items/properties (without it the touch targets are very small and annoying).

Technically, there is a value there (we call it the placeholder), but you’re right that this could likely be a point of confusion for users. We’ve specifically avoided teaching syntax structure in Grasshopper so far, to allow users to understand key coding concepts without being tripped-up over small issues.

In the (longer-term) future we do plan on giving users a more real-life IDE experience, but we’re still figuring out what that will look like.

Thank you both for your feedback!
H :slight_smile:


#48

Please help me out, I seem to have the same problem with my backpack…


#49

I am also facing issue with pack your bag problem. According to me my code is correct but it is not moving further.


#50

Hello @Wiebe_Kraak,
Your code is correct, however the solution wants you to print food and not clothes.

So change print(my backpack.clothes);
To
print(my backpack.food);

Good luck :slight_smile:


#51

Hello @tarunaaggarwal,
Can you please show your code so we can better assist you?

Thanks,
Ahsen


#52

OK… Problem fixed!:roll_eyes:


#53

I’m stuck on this problem as well.


#54

I don’t know why, I insisted writing myBackPack and it got me stuck until I saw your post. Thanks.


#55

Hey @Nolan_Code,

You don’t need to create new variables inside an object, but rather one variable called myBackpack then properties inside it, like:

var myBackpack = {
food: 'bananas'
...etc...
} 

I hope this helps!
H :slight_smile:


#56


#57

JS is case sensitive, so you need to capitalize the ‘B’, as in ‘myBackpack’.


#58

Well what @James_Boblak said is correct but your code is also partly valid. You are defining mybackpack twice which can be done but really not something you should do.

Define it as a string of just x:

var mybackpack = ‘x’;

Defined as an array:

var mybackpack = {

}

Also my guess is that grasshopper is specifically looking for the exact syntax including casing which is why it is giving an error. I hope that helps :slight_smile:

Thanks,
Ahsen


#59

Thank you it’s working God


#60


#61

Hi all,

I have the code right and running it gives me the right answer. Unfortunately though I have an extra object that I can’t remove as tapping on it and pressing the delete button removes my whole code. Please help!