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

Joseph Burdick
Joseph Burdick
11,543 Points

Return values, code challenge

Ok so I don't understand why this isn't working:

  function arrayCounter(arr){
    if (typeof arr === 'undefined' || 'number' || 'string'){
     return 0;
    } 

    return arr.length;
  }

The error displayed is : "Bummer! If I pass in an array in to 'arrayCounter' of '1,2,3' I get 0 and not the number 3."

Keith Doyle
Keith Doyle
25,973 Points

you need to include the full conditional statement after each OR.

\ if (typeof arr === 'undefined' || typeof array === 'number' || typeof array === 'string')

Keith Doyle
Keith Doyle
25,973 Points

i apologize... code view.

if (typeof arr === 'undefined' || typeof array === 'number' || typeof array === 'string')

Joseph Burdick
Joseph Burdick
11,543 Points

facepalm

Thanks for the help.

2 Answers

Great job, Keith!

Keith Doyle
Keith Doyle
25,973 Points

@Joseph Burdick, no worries! I did the same exact thing!

@Chris Akers, thanks!