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

I feel dumb. I think I've checked this code a billion times character for character. Can someone tell me what I'm doing wrong?

Here's the question:

"Create a method called 'requiredValues' that returns an array of all the values of inputs with the class of 'required'."

Here's what I put: function requiredValues(){ var $required = $(".required"); var blanks = new Array(); $required.each(function(){ blanks.push($(this).val() == ""); }); return blanks.indexOf(true) != -1; }

I've tried putting the declaration for the variable $required before the method but it didn't work that way either. HELP!!!!

4 Answers

Chase Lee
Chase Lee
29,275 Points

I don't remember it exactly, but I think you have to replace:

return blanks.indexOf(true) != -1; }

With:

return blanks;

Also here is a thread on how to display code in the forum.

Thanks but still not working

Chase Lee
Chase Lee
29,275 Points

Try taking out one of the last two semi colons.

I had just forgotten to close with a ); thanks anyway=)

Any luck???