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

create a function named 'arrayCounter'... Can you find my error?

I can't figure out what's wrong with my code... have looked through forums. Any ideas?

<!DOCTYPE html>
<html lang="en">
    <title>JavaScript Foundations: Functions</title>
      html {
        background: #FAFAFA;
        font-family: sans-serif;
    <h1>JavaScript Foundations</h1>
    <h2>Functions: Return Values</h2>

      arrayCounter(input) {
        if (typeof input === "undefined" || typeof input === "string" || typeof input === "number") {
          return 0;
        else {

         return input.length;


2 Answers

Hugo Paz
Hugo Paz
15,622 Points


You forgot the "function" keyword before arrayCounter.

Thanks so much, Hugo. Stupid mistake.