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

Around line 17, create a function named 'arrayCounter' that takes in a parameter which is an array. The function must re

Hey, not sure what I'm doing wrong here, but my code looks pretty shitty so any help would be amazing.

1 Answer

Andrew McCormick
Andrew McCormick
17,730 Points

you need to create a function that accepts a parameter and then do some conditional to test for 'typeof' to see if it's an array or not.

example:

function arrayCounter (parameter) {
        if (typeof parameter == "string") {
            alert("I am a string");
        } else {
           alert( typeof parameter);
        }
      }

If you just wan the answer see this forum post