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 "Build an Interactive > Website Form Validation and Manipulation > Checking Values" Code Challenge 2/3

Having trouble getting past this challenge "Create a method called 'requiredValues' that returns an array of all the values of inputs with the class of 'required'". Here is what I have coded:

function requiredValues(){
  var requiredValues = new Array();
  $(".required").each(function() {
    requiredValues.push($(this))
  });
  return requiredValues;
}

Not sure what I am doing wrong here but if someone who has gotten through this stage could get me on the right track I would be very grateful. Thanks.

11 Answers

The problem is with what you are pushing to your array. You want to push the value to the array.

Thanks!!! Sam for pointing out my problem; need to pay closer attention to the documentation.

I had a really hard time with that set of lessons, and I'm probably on the leaderboards for failed attempts at the challenges. Plan on grabbing a jquery book soon :stuck_out_tongue:

Woop woop! Teamwork :D

any good suggestions for jquery books? I have been hitting myself in the head on this journey. Cause i am stumped on this one. Thanks for any reply :)

Haven't picked up a book yet, but CodeAcademy has a short jQuery course: http://www.codecademy.com/tracks/jquery

Ran through their JavaScript courses quick, and they're a nice refresher and also made understanding inheritance/prototype a bit easier.

CodeSchool also has a free jQuery course, but I haven't done it yet: http://www.codeschool.com/courses/jquery-air-first-flight

Thank you very much for those suggestions :)

Hey Travis, Check out this link as well on smashing as a starting point; pretty good read and lots of other links to other resources. And practice, practice, practice..... As my martial arts instructor often shared with me - "practice makes permanent".

(http://coding.smashingmagazine.com/2008/09/16/jquery-examples-and-best-practices/)

What was the solution to this... I'm still stuck on it.

@Jameson - Create a new thread and post your code in that new thread.

@James,

Sorry about that; it's been reposted here: http://teamtreehouse.com/forum/form-validation-and-manipulation-23