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

Jquery code challenge checking-values

Ok I'm stumped on this one!

When I check my work if fails :(

There is something wrong with your code in your 'requiredValues' function.

function isValidEmail(email) { return email.indexOf("@") != -1; } var $required = $(".required"); function requiredValues() { var reqVals = new Array(); $required.each(function(){ reqVals.push($(this).val() == ""); }); return reqVals; }

5 Answers

Caroline Hagan
Caroline Hagan
12,612 Points

Elliott, can you provide a link to the Code Challenge this relates to, and where possible, post your code into something like http://codepen.io/ so we can see the bigger picture.

Many thanks :-)

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

requiredValues() should only return the values not if they equal blank or not. So removing == "" should do the trick.

I don't have =="" and my code still fails.

function isValidEmail(email) {
  return email.indexOf("@") != -1; 
};

var $required =   $(".required");
function requiredValues(){
        var reqval = new Array();
        $required.each(function() {
                    reqval.push($(this).val());
                    return reqval;}
                    );
};
Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher
return reqval;}

is in the each loop. Put it after the ); and before };