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
Andrej Kirin
18,967 PointsChallenge Problem
I'm stuck at the challenge 2. Is there anyone who knows the solution and could provide me with the code.
3 Answers
Mike Bronner
16,395 PointsI got it to work -- turns out I was misreading the question. Instead of the answer, I'll give you pseudo-code to recreate it. :) Don't want to take away all the fun for you. :)
- open function requiredValues that accepts no arguments
- declare an empty array that will hold the values
- declare an array to hold the input fields, and instantiate it using a jQuery selector to get all input fields with a class of required and convert it to an array.
- open a for loop to loop through the array of input fields
- assign the value of each input field to the corresponding index in the empty array
- close the for loop
- return the array holding the values
- close the function
Best of luck, and Merry Christmas! ~Mike
Andrej Kirin
18,967 Pointsthanks
Andrej Kirin
18,967 PointsThanks Mike, I'll take a look into challenge a bit later. You're right, it's better to have an answer like this and learn how to do it.
Merry Christmas!!
James Barnett
39,199 PointsJames Barnett
39,199 PointsThat's what I call a great example of giving help, not answers!
Mike Bronner
16,395 PointsMike Bronner
16,395 PointsThanks, James! :) Merry Christmas!