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

General Discussion

Richard Potts
Richard Potts
2,760 Points

Create a method called 'requiredValues' that returns an array of all the values of inputs with the class of 'required'.

I've found why this code is wrong but could anyone tell me why I can't declare the values array outside the scope of the requiredValues scope? var values = new Array(); var $required = $(".required"); function requiredValues() { $required.each(function() { values.push($(this).val() ) }); return values; (Also this is my first question and I can't seem to work out how to show the code as code, anyone?)