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


Nathan Marshall
Nathan Marshall
6,031 Points

Why won't my parameter be recognized anymore?

Hi Guys,

I am currently building my 'To Do List App' using only raw JavaScript. I am currently adding the functionality to not allow the user to add a string with an empty title from the input value.

I have managed to allow the user to not add anything if the value is equal to nothing. But now if I add something into the input area it doesn't allow me to add anything at all.

In the console, it says that my parameter isn't recognised any more? I have no idea why.

Could someone please explain what is going on? / How I should approach this?

Here is my CodePen: https://codepen.io/Nathan-Callum-Marshall/pen/qKJPRV?editors=0010


1 Answer

Steven Parker
Steven Parker
230,248 Points

When the input is not empty, the code on lines 98-104 calls "createTaskItems" twice, and the first time it passes no argument. Since there's no error, "createTaskItems" attempts to attach new elements to the non-existent argument, causing the program to fail.

Replace that section of code to call "createTaskItems" only once, and always with a valid argument:

  if (createTaskItems(newTask) != "error") {

Also, since you're using codepen, try using the "Tidy JS" function in the drop-down menu — particularly right before you publish. :wink:

Nathan Marshall
Nathan Marshall
6,031 Points

Yes that makes sense. Thanks for explaining that steve. You always seem to be the one solving my problems on here haha I appreciate it. I will also look up and Apply the Tidy.Js too