Ticket Time explainer

What am I doing wrong?

The error is telling me to do exactly what I’ve got in the code. What gives??? :eyes:

1 Like

There is a typo in the solution given.
Line 4 shows “for (let element of list) {”
should read “for (var element of list) {”

No it is not a typo, you can use both.

1 Like

Var is a global variable… Let is a local one. Does this clarify about the differences? Difference Between Let and Var

1 Like

If the sub of let for var is preventing my code from evaluating, then Grasshopper app is broken

No, what I meant by you can use both is that, you can use both but they are not interchangeable(at least not in every situation). So, if the app does not accept var, then it maybe be because var does not work there.

In this case, they actually are interchangeable, but I know what you mean. I’m simply saying that if my code was wrong because I used the “wrong” keyword to declare a variable in this example, then that should be considered a bug because, the keywords, are in fact interchangeable here.

If you are right and they are indeed interchangeable here then the app does not accept “var” it may be because it wants you to use “let”. That may not be a bug.

1 Like

Hey there, it looks like you’ve got a string with the text '12', instead of the number 12. Try deleting the string and using the num key on the code keyboard to input the number.

1 Like

True. Is your point that I shouldn’t worry about being creative and just follow instructions…?

I did not say that. However, for the app you can only follow the instructions a large majority of the time. You can be creative by writing code on your own.


Indeed. The app doesn’t allow for much creativity, even in the usage of let vsconst apparently

Hi there,
You are calling function inside console.log which is causing trouble. Try calling function without console.log in the last line.
Hope it helps,

Hey there, I’ve updated the solution code in the explainer to show var, because currently that’s the only declarator that can be used in a for of loop in Grasshopper.

Outside of this app, it is better to use let for a looping variable in a for of loop, as let has a different (and better) scoping behavior than var, which can prevent some weird bugs.

However, in the app, you’ll have to continue using var in for of loops for now.

Hope this helps!

plss help me

1 Like

If (element[‘age’] > 12) {

each element is an object from the studentList array and writing element[‘age’] is accessing the value of the age property in each object and element[‘name’] is accessing the value of the name property in each object that satisfy the condition age>12.
Hope I’ve been able to help you!

Thank you very much I’ve been stuck with this topic


What is wrong with that?