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

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