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.
Trevor Wood
17,828 PointsStuck on jQuery question
Not sure what I'm doing wrong here. Can anybody help out a little?
$('.required input').map(function(){
values = $(this).val();
return values;
});
2 Answers

Robert Newman
29,571 PointsYou need to create the var 'values' at the beginning.
var values = $(".required").map(function() {
return $(this).val();
});

Jon Knight
7,184 PointsYou only need to use .required as the selector and the jQuery map method returns a jQuery object, which contains an array, so you can assign the whole jQuery statement to the values variable like this .
Read more about it here
var values = $('.required').map(function(){
return $(this).val();
});
Trevor Wood
17,828 PointsTrevor Wood
17,828 PointsAhh, okay I see how this works now. Thanks!