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
Alexander Sobieski
6,555 PointsJquery Utility Methods - challenge Q 2of2 help
Code Challenge Q: Using the 'inArray' method check if the array contains the string 'Andrew'
*My answer to 1of 2 (that passed): *
var $required = $(".required");
var values = $required.map(function(){
return $(this).val();
});
The answer that I keep coming back to (but is wrong):
var $required = $(".required");
var values = $required.map(function(){
return $(this).val();
});
return $.inArray("Andrew", values);
My brain is not cooperating today
2 Answers
Andrew Chalkley
Treehouse Guest TeacherRemove the return from the last line. You cannot use the return keyword outside of a function.
Alexander Sobieski
6,555 PointsThanks @Andrew! Good to know.
I should have posted sooner, but after spinning in circles, I posted this post. By posting the post and explaining my thought process, I had an "AHA Moment" right after submitting. - I figured it out.
As with many things, walking myself through the problem caused me to make sure I was fully reading and fully thinking-through each step and requirement. Boom. Got it.