Ayah's Students explainer

Screenshot_20190914-133751_Grasshopper

I’m not sure what I’m doing wrong. Please help! I’ve tried the function and calling it but I cant figure out what I need to fix.

1 Like

Hey there, the puzzle’s completion trigger is looking for the function call needsAdultTicket(studentList), but can’t see it because the call is inside a console.log().

Try changing console.log(needsAdultTicket(studentList)) to just needsAdultTicket(studentList).

That should solve the problem! Let me know if you have any questions.
Ben

2 Likes

Focus… Is reading and comprehension…

I know you need to feed a parameter into the function to use the imported studentList array into the function, but it’s never mentioned in the instructions making it look like all the code needs to be done within the function.

Maybe addressing this in the instructions would make this more clearer for others?

3 Likes

Hey there, great feedback!

Thanks,
Ben

Hey! I‘m stuck in here, can You help me out please?

1 Like

Hey there, in your if statement, change element['age' > 12] to element['age'] > 12.

Hope this helps!
Ben

3 Likes

Already reviewed the for… of loop lesson, but I still don’t understand why it keeps telling me to make it loop through the list.


Thanks in advance.

1 Like

Hey there, looks like there are a few small issues:

list is the parameter of the function. You want to use this inside the function, so change your for loop to loop through list instead of studentList, like this:

for (var element of list)

Then, outside the function, call the function with studentList, like this:

console.log(needsAdultTicket(studentList))

Finally, in the code block of the for loop, you’re printing a string with the text 'name', rather than element['name']. Try changing it to this:

console.log(element['name'])

Hope this helps!
Ben

1 Like

It did, thanks.

I wish there was an easier way to find the needed lessons by topic, instead of going through the whole list of exercises trying to find the right one. We could all go back and review first, then bug you if we could definitely not find the solution.

Thank you again for your time and patience.

1 Like

the solution is not working. I have read some of the comment and have tried many things over the last 4 days. I’m very frustrated. Can you help me out.

Hey there,

It doesn’t look like the function is being called. Try calling it on the last line of code, outside the function declaration, like this:

needsAdultTicket(studentList)

Hope this helps!
Ben

this worked fine as is

Hey there, change the parameter of the function to list instead of studentList, then use that parameter in the for loop, like this:

function needsAdultTicket(list) {
    for (var element of list) {
        ...
    }
}

Hope this helps!
Ben

1 Like

I need help with my puzzle

It doesn’t let me write element in the parts that it is needed, but there is no element option to add it in anyway.

Hey there, when you create a for loop in Grasshopper, it will automatically fill it in with a looping variable named element, like this:

for (var element of ___) {

}

A key named element will then be added to the code keyboard.

You can double tap/click on element if you’d like to change its name.

Hope this helps!
Ben

Have you tried clicking through on the ‘Guide’ function at the top of the page? I find the guide useful in terms of how easy it is to access, and how succinct and clear the explanations and examples are.

Although I relate to what you are saying. pdf Cheatsheets might be an idea? What do you think, @Grasshopper_Ben

Can’t find “guide”. Anyway, the thing is sometimes the explainer is too clear, and practically gives you the answer. Reviewing past lessons may allow you to come up with a solution on your own, and if you still can’t and need a bit more help, you go to the explainer.

1 Like