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 Final code challange

Hey I have another problem, I completed task 1 but whatever I type in task 2 makes task 1 not passing anymore. Any clues?

This is question: Using the 'inArray' method check if the array contains the string 'Andrew'

And my code:

var $required = $(".required"); var values = $required.map(function(){return $(this).val();}); return $.inArray("Andrew", values) != -1;

Thanks in advance

1 Answer

hi I was stuck on this the other day. Your mistake is in the final part, this question is not asking for a return it just asks if "Andrew" is in the array. So get rid of the return and the $ sign. Now it says use "inArray" method and to do that use jquery.inArray() now in the () give the string your searching for in the array.

Check out the InArray Documentation to find out more.

Hope this helps because it took me days to understand lol like everyone else am finding javascript so hard.