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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Alejandro Carrillo](https://secure.gravatar.com/avatar/291b17cdb1a80058a8e51863da02f390?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Alejandro Carrillo
1,781 PointsChecking values challenge trouble
Hi, chaps!
I'm stuck with the Checking values challenge 2/3 step in the Building and interactive website course... can anyone help me?
this is what I answer :
function requiredValues(){
var blanks = new Array();
$(".required").each(function(){
blanks.push($(this).val() == "");
});
}
31 Answers
![Charlie Allombert](https://secure.gravatar.com/avatar/fea147f60bca723635deadff37235ad6?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Charlie Allombert
2,461 PointsThanks for your answer Andrew.
I'll have to agree with other people who mentioned this stage was too big of a gap with the rest of the adventure. I think having a background in server side programming would help but most people doing the HTML/CSS courses don't. I worked a tiny bit with jQuery in the past and I was completely lost and this challenge.
![Alejandro Carrillo](https://secure.gravatar.com/avatar/291b17cdb1a80058a8e51863da02f390?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Alejandro Carrillo
1,781 PointsHi, Andrew, thanks for the quick response...
I understood what you've said, and I've tried again with this, but still don't get it:
var whatever = new Array ();
function requiredValues(){
$(".required").each({
whatever.push($(this).val());
})
}
I know I'm missing something, but just can't figure it out, even watching again and again the video. :-(
![Andrew Chalkley](https://uploads.teamtreehouse.com/production/profile-photos/26170/micro_TeacherShoot-Andrew.jpg)
Andrew Chalkley
Treehouse Guest TeacherHi Alejandro,
At the end of the function you need to use the keyword return followed by the array variable.
In JavaScript the return keyword can be used at the end of a function to return a given value, a number, a string or in this case an array.
Hope this helps.
Regards Andrew
![John Locke](https://secure.gravatar.com/avatar/684abea28956f403bb98ae6bf73728fd?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
John Locke
9,450 Pointsfunction isValidEmail(text){
return text.indexOf("@") != -1;
}
var values = new Array();
function requiredValues(){
$("input.required").each({
values.push($(this).val())
});
return values();
}
Bummer null.
function isValidEmail(text){
return text.indexOf("@") != -1;
}
var values = new Array();
function requiredValues(){
$("input.required").each({
values.push($(this).val())
});
return values;
}
Also Bummer null. Copying without understanding, waiting for something to pass - that's where I'm at with this code challenge.
Please tell the development team "try to anticipate errors, and give better hints, as in the newest PHP videos".
![John Locke](https://secure.gravatar.com/avatar/684abea28956f403bb98ae6bf73728fd?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
John Locke
9,450 Pointsfunction isValidEmail(text){
return text.indexOf("@") != -1;
}
var $required = $("input.required");
function requiredValues(){
var values = new Array();
$required.each(function(){
values.push($(this).val());
});
return values;
}
This ended up working for me.
![ecp](https://secure.gravatar.com/avatar/38808e29a6fccfdb89eb2f9aaa9caaa7?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
ecp
838 PointsHey @Alejandro :D sorry you're having trouble on this challenge! Could you link us to it and perhaps send a screenshot over to help@teamtreehouse.com ?
Screenshots will help us see what quiz or code challenge your on, what it is asking you exactly, what your answer is, and what the error message or hint says to you when it pops up. :)
I've reached out to Andrew about this for ya! The offices are closed for the weekend currently (7:03ish pm EST at the moment) so there might be a slight delay in getting back to you, just so you know ^^
![Alejandro Carrillo](https://secure.gravatar.com/avatar/291b17cdb1a80058a8e51863da02f390?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Alejandro Carrillo
1,781 PointsThanks, Andrew, I finally got it... :-)
now I'm stuck with the next code challenge, though.:-(
cant' pass the second part of the jQuery utility methods.
This is what I'm answering.
var values = $(".required").map(function(){
return $(this).val();
});
$.inArray(true, values) != "Andrew";
thanks for all your help!
Cheers!
![John Locke](https://secure.gravatar.com/avatar/684abea28956f403bb98ae6bf73728fd?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
John Locke
9,450 PointsI got stuck on this too. I keep rearranging lines in the function, I'm watching the video while I do this, and I still feel like I don't understand this at all.
![Andrew Chalkley](https://uploads.teamtreehouse.com/production/profile-photos/26170/micro_TeacherShoot-Andrew.jpg)
Andrew Chalkley
Treehouse Guest TeacherHi John,
When there's a JavaScript syntax error it does the Bummer! null error, the development team are aware of this issue and are working on a solution to show the syntax error as the hint.
Hi Alejandro,
The inArray method returns a number or position of the element in the array.
So in your example tweaked $.inArray("Andrew", values) != -1 means if the string "Andrew" is not in the array values it'll return minus one and the not equals (!=) means it'll return true or false if present.
![John Locke](https://secure.gravatar.com/avatar/684abea28956f403bb98ae6bf73728fd?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
John Locke
9,450 PointsThanks for your detailed reply, Andrew. JavaScript is definitely the chink in my front-end armor. It takes me a while to really see what you probably see instinctively. Glad you are on the team. :)
![Matt Carr](https://secure.gravatar.com/avatar/a8c130e9e85441662b126a1a5ea8acd9?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Matt Carr
9,654 PointsThe JavaScript/JQuery tutorials make me feel a little dumb. The difficulty of this challenge seemed to jump from the previous quizzes. I hope that if I just push through the videos it will come together in the end.
![Sergio Sala](https://secure.gravatar.com/avatar/596a614664b737618258451d9d377798?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Sergio Sala
5,189 PointsI'm having the same trouble even had to find this thread to do something..
JQuery and Validation form videos are not so easy to understand :/
But I guess it takes some time..
![Campaign Monitor](https://uploads.teamtreehouse.com/production/profile-photos/51870/micro_01_Marque_Medium_Blue.jpg)
Campaign Monitor
3,102 PointsI was having issues with this challenge too. The 'wrong answer' messages I was getting simply stated that something was wrong with my code.
![Nauman Ahmed](https://secure.gravatar.com/avatar/ff4f6ee66db4e06a32741a65147ce6ce?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Nauman Ahmed
3,154 PointsHi,
I am also stuck in the checking values challenge 3/3
Q: Create a method called 'containsBlanks' that returns true if any inputs with class 'required' has an empty string in, false if not.?
This is what i am doing. Please advise.
function containsBlanks() {
$(".required").each(function(){
$(this).val() == " ";
});
}
Thanks.
![Nauman Ahmed](https://secure.gravatar.com/avatar/ff4f6ee66db4e06a32741a65147ce6ce?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Nauman Ahmed
3,154 PointsIs there anyone who can help me with my question above please?
Thanks.
![ecp](https://secure.gravatar.com/avatar/38808e29a6fccfdb89eb2f9aaa9caaa7?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
ecp
838 PointsHi Nauman,
Try reading the responses from other Teachers and Students above! :) I've let our Teachers know you need help, but there might be a slight delay in getting back to you. Our offices are currently closed for the weekend. :) Mind sending me your work directly? Get in touch by emailing us at help@teamtreehouse.com. I'll get you connected with our Teachers.
Best,
Elizabeth
![Andrew Chalkley](https://uploads.teamtreehouse.com/production/profile-photos/26170/micro_TeacherShoot-Andrew.jpg)
Andrew Chalkley
Treehouse Guest TeacherHi Nauman,
There's a couple of things missing
- You don't have an array to store the test you're performing i.e.
$(this).val() == " ";
- You need to test if the array has a
true
in or not and return that on the last line of thecontainsBlanks
function. -
" "
is an a string with a space in it. An empty string looks like""
.
Hope these pointers help.
![Nauman Ahmed](https://secure.gravatar.com/avatar/ff4f6ee66db4e06a32741a65147ce6ce?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Nauman Ahmed
3,154 PointsHi,
Thanks for your reply. Just wanted to make sure we are on the same page. I am talking about the challenge number 3/3.
Q: is "Q: Create a method called 'containsBlanks' that returns true if any inputs with class 'required' has an empty string in, false if not.?"
I created the method called containsBlanks
//method called containsBlanks function containsBlanks() { //This line identifies the selector and creating anonymous function which gets the value of .required and returns the value of true or false? $(".required").each(function(){ $(this).val() == ""; }); } Do I return $(.required); at the end? I am still not sure what I am doing wrong... Sorry if my question doesnt make sense :-(
![Nauman Ahmed](https://secure.gravatar.com/avatar/ff4f6ee66db4e06a32741a65147ce6ce?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Nauman Ahmed
3,154 Points//method called containsBlanks
function containsBlanks() {
//This line identifies the selector and creating anonymous function which gets the value of .required and returns the value of true or false?
$(".required").each(function(){
$(this).val() == "";
}); }
Do I return $(.required); at the end? I am still not sure what I am doing wrong...
![Andrew Chalkley](https://uploads.teamtreehouse.com/production/profile-photos/26170/micro_TeacherShoot-Andrew.jpg)
Andrew Chalkley
Treehouse Guest Teacherfunction containsBlanks() {
//Create an array here
$(".required").each(function(){
$(this).val() == ""; //Put this value on to the array
});
//return true or false here depending on the contents of the array. I showed one what of doing it in the video.
}
![Andrew Chalkley](https://uploads.teamtreehouse.com/production/profile-photos/26170/micro_TeacherShoot-Andrew.jpg)
Andrew Chalkley
Treehouse Guest Teacherfunction containsBlanks() {
//Create an array here
$(".required").each(function(){
$(this).val() == ""; //Push this value on to the array
});
//return true or false here depending on the contents of the array. I showed one what of doing it in the video.
}
Added some comments :)
![Nauman Ahmed](https://secure.gravatar.com/avatar/ff4f6ee66db4e06a32741a65147ce6ce?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Nauman Ahmed
3,154 PointsThanks for your reply Andrew. I have added a new array and pushed the value on to the array. its still not working:(
$req = $(".required");
function containsBlanks(){
var blanks = new Array(); // new array here
$req.each(function() {
blanks.push($(this).val() == "" ); // pushing the value on to the array
});
return blanks; // returning true or false
![Nauman Ahmed](https://secure.gravatar.com/avatar/ff4f6ee66db4e06a32741a65147ce6ce?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Nauman Ahmed
3,154 Pointsending curly bracket is also there after "return blanks;" I forgot to paste it in the code. sorry!
![Andrew Chalkley](https://uploads.teamtreehouse.com/production/profile-photos/26170/micro_TeacherShoot-Andrew.jpg)
Andrew Chalkley
Treehouse Guest TeacherYou're almost there Nauman.
So at the moment you have an array called blanks that contains true
s and false
s. So you need to figure out if the blanks array has a true
in it.
Once you've figured that out then you can return true
or false
.
The previous video talks about 2 methods. One using indexOf
which isn't cross-browser compatible and using another algorithm.
![Nauman Ahmed](https://secure.gravatar.com/avatar/ff4f6ee66db4e06a32741a65147ce6ce?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Nauman Ahmed
3,154 PointsFinally,
I used sort and pop method to return true OR false.
return.blank.sort().pop();
It worked :-) Thanks for all your help........
Thanks.
![Charlie Allombert](https://secure.gravatar.com/avatar/fea147f60bca723635deadff37235ad6?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Charlie Allombert
2,461 PointsI have the following and I get this error: Oops! It looks like Task 1 is no longer passing. (Even though, I haven't touched the first function), can anybody help with this ?
function isValidEmail(email){
return email.indexOf("@") != -1;
};
var $required = $(".required");
function requiredValues(){
var values = new Array();
$required.each(function(){
values.push($(this).val());
});
return values;
};
var $required = $(".required");
function containsBlanks(){
var blanks = new Array();
$required.each(function(){
blanks.push($(this).val() == "" );
};)
return blanks.sort().pop();
};
![Charlie Allombert](https://secure.gravatar.com/avatar/fea147f60bca723635deadff37235ad6?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Charlie Allombert
2,461 PointsI managed to finish the challenge with the code above but I've got not idea what's the difference between mine and his (except for the variable having a different name) ?
![Andrew Chalkley](https://uploads.teamtreehouse.com/production/profile-photos/26170/micro_TeacherShoot-Andrew.jpg)
Andrew Chalkley
Treehouse Guest TeacherI get an SyntaxError: Unexpected token ; with the code you posted above Charlie. Is suspect it was this };)
here should have been });
. Putting a semi-colon before a )
like that will terminate the line and that )
is just dangling there.
If previous steps fail in a code challenge it's often due to a syntactical mistake. I know the app team are working on making the error hints better but in the mean time keep an eye out for syntax issues for tasks that no longer pass.
![Andrew Chalkley](https://uploads.teamtreehouse.com/production/profile-photos/26170/micro_TeacherShoot-Andrew.jpg)
Andrew Chalkley
Treehouse Guest TeacherThanks for the feedback.
We'll be working on narrowing that gap with upcoming content releases.
Keep an eye out on our roadmap as things progress.
![Maximiliane Quel](https://uploads.teamtreehouse.com/production/profile-photos/124432/micro_profile-pic.png)
Maximiliane Quel
Courses Plus Student 55,489 PointsI'd like to join the others in saying that this code challenge has been impossibly difficult. And while it took ages to figure out what was supposed to happen in step two, I spend even more time trying to figure out how to employ the code of step two in step three. Is that possible? Where we supposed to try that? Otherwise, why are we returning the values of of the required fields or is that just a proof of concept? I am still confused.
![Jon Edwards](https://secure.gravatar.com/avatar/0e888ae6a583fe4aebf65573237743d5?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Jon Edwards
7,913 PointsI ran across this thread searching for help on this same code challenge.
I agree its complicated but that's how it is with programming from what I can tell. More important to understand what they are doing and why, then just follow along in the code copying what they type. Over time the syntax becomes more apparent, and can always be debugged!
When I have trouble I rewatch each video and listen as he describes each step, then slowly it starts to make sense, each code challenge uses the same techniques he describes. Good Luck!
(I realize this is an old thread but many will come across this looking for help!)
![Andrew Chalkley](https://uploads.teamtreehouse.com/production/profile-photos/26170/micro_TeacherShoot-Andrew.jpg)
Andrew Chalkley
Treehouse Guest TeacherHi Alejandro,
The question is:
Create a method called 'requiredValues' that returns an array of all the values of inputs with the class of 'required'.
Not if they contain blanks or not :)
Let me know how you get on!
Regards
Andrew