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 trialSatish Mohan
2,055 PointsMissing function error
function arrayCounter (my_array[]) {
if (typeof my_array === 'undefined' or typeof my_array ==== 'string' or typeof my_array === 'number') {
return 0;
}
return my_array.length;
}
Can't figure out the error. Please help.
1 Answer
Dave McFarland
Treehouse TeacherYou don't use or
in an if statement like that. Instead use two "pipe" characters -- ||
-- to indicate "or".
Also, the argument in the arrayCounter function, doesn't need []
characters:
function arrayCounter(my_array) {
Dave McFarland
Treehouse TeacherDave McFarland
Treehouse TeacherHi Satish Mohan
There's a special way to format code int he forum. I fixed your code in this post but in the future, you can follow the steps listed in this post:? https://teamtreehouse.com/forum/posting-code-to-the-forum