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
Michael Kornblum
17,362 PointsNeed help with interactive website code challenge.
On the Build an Interactive Website island there is a code challenge that says verbatim:
Create a method called 'requiredValues' that returns an array of all the values of inputs with the class of 'required'.
This is the accompanying html:
<!DOCTYPE html>
<html>
<head>
<title>Modifying Attributes</title>
<style type="text/css">
.valid {
color: green;
border: 2px solid green;
}
.error {
color: red;
border: 2px solid red;
}
</style>
</head>
<body>
<p>
<input type="text" class="required" id="name" value="Andrew">
</p>
<p>
<input type="text" class="required" id="company" value="Treehouse Island, Inc">
</p>
<p>
<input type="text" class="" id="phone" value="555-123-4567">
</p>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="app.js"></script>
</body>
</html>
This is my solution:
function requiredValues() {
var array = new array();
$('input.required').each(function () {
array.push($(this).val());
});
return array;
}
After banging my head against this problem and getting repeated nulls, I'm at my wits end, wondering where I'm going wrong.
2 Answers
Michael Kornblum
17,362 PointsOkay, I had no idea that objects in javascript were case sensitive. My bad. lol.
Cullum Stuart
Courses Plus Student 6,441 PointsThank you sooooooooooo much. I was having the same problems and was getting ready to through my computer out the window!!!