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 trialCaroline Rawson
2,174 PointsJavascript foundations, Functions, Return values challenge
I am getting an error for the Return Values challenge and I don't understand why.
Here's my code:
function arrayCounter (function_array) {
if (function_array.isArray){
return function_array.length;
}
if (typeof function_array === ('string' | 'number' | 'undefined')) {
return 0;
}
}
I am getting the following error: Bummer! You're not checking if 'undefined' is being passed in
Why is my check for undefined not working?
thanks!
Adam Sackfield
Courses Plus Student 19,663 PointsGreat that you found the solution yourself. For future ref i found another post here with the same question answered link
Caroline Rawson
2,174 PointsCaroline Rawson
2,174 PointsOk I realised that my OR operators were incorrect...
My use of isArray() was also incorrect - so I guess the first bit of code was being ignored and that's why the error related to the checking of undefined, which threw me a bit! Fixed these and now it's working :-)
My answer: