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

wrong error

I have tried this code challenge and keep getting the missing a function named arrayCounter, I am not certain my code is correct, but I did think I labeled the function correctly at least. Any help on this would be appreciated.

Steve Wamsley
Steve Wamsley
7,977 Points

Can you please provide your code and the error message you are getting?

Chris Dziewa
Chris Dziewa
17,781 Points

Please paste your code here within a pair of three backticks so we can help.

1 Answer

Chris Dziewa
Chris Dziewa
17,781 Points

Since I may not be able to respond later today, I am posting a working version of the function. Spoiler Alert If you want to work through it more, feel free to not check this until you have tried more variations otherwise, you can compare your code to mine.

<script>
function arrayCounter( list ) {
        if(typeof list == 'string' || typeof list == 'number' || typeof list == 'undefined') {
            return 0;
        }
        else {
            return list.length; 
        }

      }
</script>