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 trialNeil Berriman
3,230 Pointsjquery code challenge
I am stuck on this can anyone help? Using the 'inArray' method check if the array contains the string 'Andrew'
My answer is,
return $.inArray(true, Andrew) != -1;
When I put my answer in it does not come up with a Bummer it sends me back to previous task.
Kind regards, Neil
2 Answers
Stone Preston
42,016 PointsAndrew needs to be a string. Where you have (true, Andrew), andrew is not a string so you are getting an error because the inArray method doesnt recognize the argument.
Its been a while since ive worked with jQuery so I could be wrong.
Paul Ozag
11,369 Pointsi am not sure but i think one of the arguments in the $.inArray method is the name of the array. cant remember but i think it's the first argument and the string 'Andrew' is the second.
Neil Berriman
3,230 PointsHow do I write Andrew as a string...?
Paul Ozag
11,369 Pointsput either single or double quotes around it : 'Andrew' or "Andrew"
Neil Berriman
3,230 PointsHi Paul,
My answer is this their are 3 blanks the 1st is 'Andrew' this is my code I have tried.
return $.inArray(true, 'Andrew') != -1; I have also tried this next code.
return $.inArray(true, blanks) 'Andrew' != -1; I have also tried this next code. return $.inArray(true, blanks 'Andrew') != -1;
Can you help please...?
Neil
Paul Ozag
11,369 Pointstry this: return $.inArray (blanks, 'Andrew') != -1;
Neil Berriman
3,230 PointsHI Paul,
I have tried this still no joy....I will ask the help team if they can put me intouch with Andrew Chalkey.
Unless you have any more idea's..?
Regards,
Neil
Neil Berriman
3,230 PointsHi Paul,
Finally got the correct code this is it:
var values = $(".required").map(function(){ return $(this).val() }); $.inArray("Andrew", values);
I hope this makes sense to you.
Neil
Neil Berriman
3,230 PointsNeil Berriman
3,230 PointsHi Stone,
How do I write Andrew as a string..?
Regards,
Neil