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.

Graham Davidson
Courses Plus Student 14,966 PointsCode Challenge JQuery
Ok so I promised myself I would ask but I have been seriously working through this badge and code challenge all afternoon and its driving me nuts.
Create a method called 'requiredValues' that returns an array of all the values of inputs with the class of 'required'. The first function is the answer to the previous code challenge - which I passed.
Can anyone tell me what is wrong with the second function please.
function isValidEmail (email) {
return email.indexOf("@") != -1;
}
function requiredValues () {
var blanks = new Array();
inputs.required.each(function(){
blanks.push($(this).val());
})
return blanks;
}
2 Answers

Stone Preston
42,016 PointsYour inputs.required needs to be a jquery object. Since .each() is a JQuery method you need to turn your CSS selector into a Jquery Object like so $("selector") . I think that will fix your issue.
edit: also it looks like you may be missing a semicolon at the end of your anonymous function block.

Chase Lee
29,275 PointsHere is a link to the question: https://teamtreehouse.com/forum/create-a-method-called-requiredvalues-that-returns-an-array-of-all-the-values.
Graham Davidson
Courses Plus Student 14,966 PointsGraham Davidson
Courses Plus Student 14,966 PointsLegend - thank you Stone