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

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.