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 trialPaul Magnuson
5,965 PointsChallenge Task for Return Values
Help me out with process in Treehouse - when I get stuck, like I currently am, I don't see where I can get advice, or hints ... I'm just left flat out stuck. I don't get what I should do, so I end up halting entirely instead of getting assistance to get over something I initially don't get. Am I missing something in Treehouse for learners that would address this gap? Thanks!
6 Answers
Chase Lester
10,972 PointsJason Ziegler -- try putting in the argument "array" instead of "x". function arrayCounter(array) then replace x with array. You can also try this code below:
function arrayCounter (array) {
if (typeof array === 'undefined' || typeof array === 'string' || typeof array === 'number') {
return 0;
}
return array.length;
}
Nicholas Olsen
Front End Web Development Techdegree Student 19,342 PointsPost about it in this forum and we'll try and help you as best we can.
What is the challenge, and what is your code?
Chase Lester
10,972 PointsThe forums are you best help. People usually answer pretty quick. Also another thing is, a lot of the challenge questions have already been asked by someone, so just copy the question you are stuck on, and paste into google and more than likely you will find that its been asked and you can see the answer
Paul Magnuson
5,965 PointsChase, that helps. Thanks.
Jason Ziegler
Full Stack JavaScript Techdegree Graduate 39,583 PointsI am having trouble with this challenge, also.
here is what I have so far:
function arrayCounter(x) { if (typeof x === 'undefined') { return 0; } if (typeof x === 'string') { return 0; } if (typeof x === 'number') { return 0; } if (typeof x === 'array') { return x.length; } }
Jason Ziegler
Full Stack JavaScript Techdegree Graduate 39,583 PointsYou can't use typeof with "array" I had to use the following code:
if (typeof array === 'object') {
return array.length;