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

I don't understand how I should write this code, can you help me with some hints?

Can someone help me?

index.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>JavaScript Foundations: Functions</title>
    <style>
      html {
        background: #FAFAFA;
        font-family: sans-serif;
      }
    </style>
  </head>
  <body>
    <h1>JavaScript Foundations</h1>
    <h2>Functions: Return Values</h2>
    <script>
       function arrayCounter (arrayCounet){
        if(typeof arrayCounet === 'string'){
        return 0;
        }
        if(typeof arrayCounet === 'number'){
        return 0;
        }
        if(typeof arrayCounet === 'undefined'){
        return 0;
        } if(typeof arrayCounet === 'array'){

        return arrayCounter.length;
        }
      }


    </script>
  </body>
</html>

1 Answer

Alen Todorov
Alen Todorov
1,577 Points

On the return section you returned the functions' length instead of the parameters.

Try this:

return arrayCounet.length;