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 trial

JavaScript JavaScript Foundations Functions Return Values

Missing 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.

Dave McFarland
Dave McFarland
Treehouse Teacher

Hi 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

1 Answer

Dave McFarland
STAFF
Dave McFarland
Treehouse Teacher

Satish Mohan

You 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) {