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 trialsamiff
31,206 PointsjQuery Checking Values Task3/3 from Build an Interactive Website
Having a bit of trouble with Task 3/3: "Create a method called 'containsBlanks' that returns true if an array of required values has any blanks in it, false if not."
This is what I'm trying so far:
function containsBlanks()
{
var myArray = requiredValues();
return (myArray.indexOf("''") > -1);
}
SOLVED: I was testing for the wrong string value inside of my indexOf; "" vs "''"
Edit: I also can't seem to get the Markdown to work, I'm putting 4 spaces in front of every code line, and it's still not taking? Is there a manual tag I can use?
7 Answers
Andrew Chalkley
Treehouse Guest TeacherGood to see you figured it out.
If you separate the line before the code example it will indent it correctly. I edited it for you. You should be able to edit and see what I did.
samiff
31,206 PointsAwesome, thanks for your help on that!
Paul Hess
1,239 PointsHi Sam,
I'm stuck on the previous to this, Checking Values Task 2/3 from Build an Interactive Website.
Could you help please, I feel clueless on this.
Thanks!
Here's what I've done
function isValidEmail(email){ return email.indexOf("@") != -1; }
var $required = $(".required")
function requiredValues(){
var inputs = new Array();
$required.each(function(){
$(this).val();
});
}
Paul Hess
1,239 PointsNo need. Sorted it now. Thanks anyway.
Anne Maiale
1,495 PointsI'm trying this same exact function as above but still not passing. Here's my whole code for this section:
function isValidEmail(email) {
return email.indexOf("@") > -1;
};
function requiredValues() {
var myArray = new Array();
$("input.required").each(function () {
myArray.push($(this).val());
})
return myArray;
}
function containsBlanks() {
var myArray = requiredValues();
return (myArray.indexOf("''") > -1);
}
samiff
31,206 PointsmyArray.indexOf("''")
vs
myArray.indexOf("")
Andrew Chalkley
Treehouse Guest Teacher+1 Sam's reply!
Thanks for chipping in!