Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects The Student Record Search Challenge Solution

Is the var " NotInList" correct?

Hello

another student wrote this code(I asked this question to him in a comment, but never got an answer, I guess he hasn't seen it yet) ( challenge 3 from js objecst video):

Imgur

I'm kinda confused with this variable " notInList". Did he mean to say " onTheList" instead?

I changed that variale to - "onTheList" and that makes more sense to me. For example:

Imgur

on line 54, if I type the name "Andrew", that is obviously not on the list,(The list of students that he made).

so (!onTheList) = not on the list. I might be wrong, a clarification is greatly appreciated.

thanks.

Josh Olson

I think the code is not running because that's just part of the code. The whole thing is in this link:

https://teamtreehouse.com/community/finally-got-extra-credit-code-done-here-it-is

They are 2 javascript files. students.js and student_report.js.

take care

1 Answer

It appears your intuition is correct, the name notInList is misleading the way it is used.
Made clear in the last bit of code where it prints the message that the search term is not in the list if ! notIntList is true -- which would be not-notInList or INLIST! And also when the variable is assigned to true, when the name is found in the first if block of the for statement. Good catch.

Thanks mkmk, that's what I thought.