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

Build an Interactive Website --> Form Validation and Manipulation --> Checking Values

While trying to complete the 3rd challenge in the above topic with the following question:

Create a method called 'containsBlanks' that returns true if an array of required values has any blanks in it, false if not.

I have struggled to make many different approaches to this problem work when clicking 'check my work'

approaches that were used were: 1) looping over the array and checking the indexOf value for each string within the array 2) looping over the array and checking the length of the strings are not equal to 0 3) using the jQuery inArray method from the API 4) various other approaches stolen from stack overflow

I also struggled to understand whether the array was passed in as an argument to the function or whether we should call the 'requiredValues()' from the 2nd challenge..

Please help me! I really want this badge! I have been very happy with all of the other challenges on this site thus far.

Yours sincerely (Badge Master Zurg)

2 Answers

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Hi Damien,

It'd be cool to see all of the ways you've tried it in code and we can then make each one work :)

But here's an outline to get you going.

//Define 'containsBlanks'
  //Create an array called anything you want
  //Cycle over the required fields using each
    //As in the video push the result of weather the value of the field is an empty string
  //Return the result of the sorted array's last entry (sort and pop)

Hope that helps.

Andrew

Yes. This did help, although it does seem a little different to what the original question was asking!

Maybe I should watch more videos before attempting the challenges blindly!

Thank you for your kind attention.

Badge Master Zurg