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 trialbenjamin perodeau
7,469 Pointsoy
function containsAndrew(){
var values = $(".required").map(function(){
return $(this).val('Andrew');
});
return $.inArray('Andrew', values) != -1;
}
This is what happens when I keep failing and getting the same lazy, generic error message. I add stuff, step-wise, scientifically, to see if any of my ideas result in a different, less generic error message. Nope. Exhales This jQuery project is fit for buzzard feed. Treehouse should pay me approx $25 for every hour I've wasted on this garbled mindvomit of a lesson.
4 Answers
benjamin perodeau
7,469 PointsBOOOOOOM goes the dynamite!
var values = $('.required').map(function(){
return $(this).val();
});
$.inArray('Andrew',values);
Jason Anello
Courses Plus Student 94,610 PointsYou're writing more code than what they are asking for. I think you'll have an easier time if you read the instructions carefully and take them literally. Only do what they tell you to do.
Task 1 instructions are: Call 'map' on the inputs with the class 'required' and return each of their values and store it in a variable named 'values'.
They don't ask you to write a function. So putting your code inside a function is going to cause it not to pass.
The first statement in your function is pretty close to what they're asking for in task 1. They want you to return the values of the required fields.
When you use val('Andrew')
, it means, "set the value to 'Andrew'".
When you use val()
, it means, "retrieve the value"
See what you can come up with for task 1 and post your results if you're still stuck.
benjamin perodeau
7,469 Pointslogging attempts below:
fail one: generic error='task 1 no longer passing'
var values = $('.required').map(function(){
return $inArray(true, values) == 'Andrew';
});
fail two: generic error = 'task 1 no longer passing'
var values = $('.required').map(function(){
return $(this).val();
});
return $inArray.(true, values) != -1;
three: same error
var values = $('.required').map(function(){
return $(this).val() == 'Andrew';
});
return $inArray.(true, values) != -1;
nope
var values = $('.required').map(function(){
return $(this).val();
});
var values = $('.required').map(function(){
return $(this).val();
});
$inArray.val()=='Andrew';
in these few attempts I tried different combinations of == and ===, both on the return line and the inArray line. nada.
var values = $('.required').map(function(){
return $(this).val();
});
$inArray.(true, values) === 'Andrew';
benjamin perodeau
7,469 Pointsto clarify: I've cleared task on and these are for task two.