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 Build an Interactive Website Form Validation and Manipulation Checking Values

Brian Schmitz
Brian Schmitz
11,167 Points

Finding the values of the array in the class of required.

Can someone please help correct this code to pass the challenge. Need to add the array to the values of the class required.

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

Brian Schmitz
Brian Schmitz
11,167 Points

Never mind, figured this one out. Thanks

I hadn't seen your comment yet when I posted.

1 Answer

Hi Brian,

You don't have anything inside the curly braces for the anonymous function passed into the .each method. Your blanks.push statement should go in there and then when that's done looping you can return the blanks array at the end of the requiredValues function.

var $required = $(".required");
function requiredValues () {
  var blanks = new Array();
  $required.each (function () {
    blanks.push($(this).val());
  });
  return blanks;
}
Brian Schmitz
Brian Schmitz
11,167 Points

No problem, thanks for helping anyway. Do you have an idea on the other post I put up with finding "Andrew" in the array. Can't figure out where I'm wrong there

Can you add the link in your other post?

Brian Schmitz
Brian Schmitz
11,167 Points

I added the link to the challenge. Let me know if you were looking for something else. I passed the first challenge but hit a snag on the second. I know its something pretty simple I'm missing.