Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

charlesporter
charlesporter
3,308 Points

Interactive Website - Code Challenge - Checking Values - can't get my code to work

Hello Internet, I cant seem to get my code to work for the Checking Value Code challenge for interactive Websites 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 looks like this:

var $required = $(.required);
function requiredValues(){
     var valuesof = new Array($required);
     return valuesof;
}

3 Answers

Hi C P,

It looks like your code is returning an array which contains all the html elements with the required class. Rather than the elements themselves, the function should be returning the values of those elements.

charlesporter
charlesporter
3,308 Points

I believe I understand what you are saying but I cant seem to get a method together that passes. It appears you are telling me to deal with the return line but I cant find a .value or anything like that that will work. Please provide a hint or something that may lead me in the right direction.

charlesporter
charlesporter
3,308 Points

I kept working at it and got all three code challenges. I actually found another treehouse forum discussion that was helpful. The foundation for this type of code is not taught very well in this section and needs to be reformatted.