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.

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.