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

samiff
samiff
31,206 Points

jQuery 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
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Good 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
samiff
31,206 Points

Awesome, thanks for your help on that!

Hi 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(); });
}

No need. Sorted it now. Thanks anyway.

Anne Maiale
Anne Maiale
1,495 Points

I'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
samiff
31,206 Points
myArray.indexOf("''")

vs

myArray.indexOf("")