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

Need help with a code challenge

Need some help please, the task goes like this:

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

My code is this:

var $required = $(".required")
var blanks = new Array()
function requiredValues(){
  $required.each(function(){
    blanks.push($(this).val() == "")
  })
  return blanks.sort().pop()
}

Hey Julio!

I formatted you code to make it stylin'

To do this yourself, check out the Markdown Cheatsheet link right above the Post comment button.

2 Answers

I can see a couple of syntax errors right off the bat.

I'm not sure that your .required needs the quotations since it's an id, not a string. And your requiredValues function should be IN the parenthesis, not in front. It looks like you also have an extra parenthesis in front of your second function that needs to be eliminated. Go over your code again and look really hard for syntax errors and extra characters.

I'm just learning too, so I may be wrong in my diagnosis. Also, wrap your code in ``` so that it shows exactly as you typed it in the Workspace.

Thanks Byron! I didnยดt notice the syntax errors. And thanks for the tip of wrapping the code. Best Regards!