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

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
229,644 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!