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


Code Challenge Question: Checking Values

This is suppose to store all the values from required into an array and then return the array. It all looks like proper syntax to me. But, I don't know if i'm missing something? Please help.

var $require = $(".required");

function requiredValues ()
  var req = new Array();
    return req;

function isValidEmail (email)
 return email.indexOf("@") != -1;

5 Answers

Chase Lee
Chase Lee
29,275 Points

He is talking about a jquery code challenge here (the one he is having problems with is task two).

It look like you are following the websites course, which is what I did in the beginning of learning Treehouse. Your probably not learning or remembering much which is what happend to me too.

Try following the Become a Web Designer Learning Adventure. After starting that everything made much more sense to me.

yeah I know it doesn't serve much of a higher purpose its just how they specifically defined the problem. I've done plenty of java coding, but I haven't quite gotten the syntax of javascript or jquery yet, but i'm hopeful. Thanks!


I'm having the same problem with this challenge.. I keep getting the error message "null" and I can't figure out what's the problem. can some one help me please? here's my code:

function isValidEmail(email){
return email.indexOf("@") != -1;
var $required = $(".required");
function requiredValues() {
var blanks = new Array();
Hunter MacDermut
Hunter MacDermut
15,865 Points

Also getting "null" on this. Tried the various answers given in this thread to no avail. Would like to move on. Anyone from Treehouse interested in helping us out?

Hello.I have the same problem.Do it like this.

function isValidEmail(email) { return email.indexOf("@") != -1; }

var $required = $("input.required");

function requiredValues() { var oArr = new Array(); $required.each(function(){ oArr.push($(this).val());

}); return oArr; }

Arijit Bhattacharya
Arijit Bhattacharya
4,563 Points

First, if you are referring to this week's JavaScript Validation challenge, which I think you are, you cannot use jQuery

You cannot use jQuery or any third party library to help you out. The code must be written only in JavaScript.

Anyways, lets get back to the question.

each() is a jQuery Object method. So, to use it you need to refer a method of jQuery object.

For your code, it will look like,


Here is a neat version of your code.

var require = $(".required");

function requiredValues(){
    req = [];

    $(require).each(function(index, element){

    return req;

But I don't the see the purpose of your requiredValues() function. It just copies the content of the jQuery object, $require into a new array.