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 trialfancygiraffe
2,785 PointsWhat's wrong with this code?
I've followed the solution step-by-step and my solution still isn't running. Please halp!
3 Answers
KRIS NIKOLAISEN
54,972 PointsOn line 20 you have:
if (search = null
It should be:
if (search === null
fancygiraffe
2,785 PointsGreat catch!
Can you help me understand the logic behind why the first line (search = null) is causing the rest of the program not to function?
KRIS NIKOLAISEN
54,972 PointsIf you add the following to your code and watch the console:
for (var i = 0; i < students.length; i += 1) {
student = students[i];
console.log(student.name)
console.log(search)
if ( student.name === search ) {
You will see search now has a value of false when using the assignment operator in the if statement. Since there is no match nothing is printed to the screen.