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

Help with checking values challenge task 2 of 3

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

My code:

var $require = $("input.required");
function requiredValues(){
  var blank = new Array();
  $require.each(function(){
    blank.push($(this).val == "");
  });
  return blank.sort().pop();  
}

I can't see where I'm going wrong?

4 Answers

It looks like your writing code for a 'containsBlanks' function as he did in the video. Keep in mind that this assignment has to return an array containing the values of all input elements with the class of 'required'.

To point you in the right direction, look at lines 5 and 7 again. Also, to make it easier for you to understand, consider changing the array 'blank' to something a bit more descriptive of what it is supposed to contain.

I'm also lost on this one

Thanx for your comments but it hasn't help and I still as lost as I was in the beginning. Changing 'blank' for something else doesn't better my understand of what is required.

A bit more help on where and why I'm going wrong please? If you could help out on this one @Andrew Chalkley that would be great!