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!
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
Pedro Baumann
12,815 PointsCode Challenge: jQuery, containsBlanks method
Hi there, I've been struggling with this for the past hour and cannot seem to find the error.
Fisrt my code:
function isValidEmail(email){ return email.indexOf("@")!=-1; }
var $required = $('.required');
function requiredValues()
{
var value = new Array();
$required.each(function()
{
value.push($(this).val());
});
return value;
}
function containsBlanks()
{
var blanks = false;
var req = requiredValues();
var len = req.length;
for(var i = 0, i < len, i++)
{
if (req[i] == "")
blanks = true;
}
return blanks;
}
Whenever I define the last function it starts saying That the first function has stoped working. I have tried many different ways of defining my thrid function containsBlanks and it always gies the same error. I haven't even managed to see if it it well written!!!
1 Answer

Drew Butcher
33,160 PointsJust a guess: doesn't var len = req.length need to be var len=req.length();
Pedro Baumann
12,815 PointsPedro Baumann
12,815 PointsIndeed Drew, thanks for noticing, I reckon I was having a bad case of"it's almost 2 am and I'm still here struggling with code..." I solved it in another way this monrning at the first try....
I will retry it with that code, thanks a lot!