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 trialzvi raphael
3,225 Pointshaving difficulties with challenge 1, thank you
Around line 17, create a function named 'arrayCounter' that takes in a parameter which is an array. The function must return the length of an array passed in or 0 if a 'string', 'number' or 'undefined' value is passed in.
2 Answers
ntcoder
2,180 Pointsfunction arrayCounter(a){ if (typeof a === "string") { return 0; } else if (typeof a === "number") { return 0; } else if (typeof a === "undefined") { return 0; } return a.length; }
Denisse Cabieses
6,411 PointsHi Zvi! Check here: https://teamtreehouse.com/forum/used-an-if-else-statement