Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Damian Szymanski
Damian Szymanski
11,843 Points

Javascript code not working.

Hello! I am trying to create a user search using indexof() and HTML forums but my JS does not seem to be working. when I try to display to user's info (Not real info), it does not show it or provide me with an error message.

Hopefully, you brilliant people can help!

CodePen: https://codepen.io/Melon_Max/pen/PgELzX

Thanks! Damian.

2 Answers

Steven Parker
Steven Parker
220,415 Points

There seem to be a few issues, including:

  • the HTML calls "SearchInfo()" (capital "S"), but the function is "searchInfo" (little "s")
  • in the function, "getSearchPrint" is called with an argument of "student", but nothing by that name is defined
  • "getSearchPrint" performs this curious test: "if (user.name === user[i].name)"
  • while searching for the right user, "searchInfo" prints the "No user" message for every _other_user

There may be a few more, but that should get you started.

Damian Szymanski
Damian Szymanski
11,843 Points

Thank you so much! It really helped!