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 trialmichaelkyllo
11,330 Pointsparameter 1 is not of type 'Node'.
I have been trying to figure this out on my own and I can't understand what is wrong with one part of my code.
// Problem: User interaction doesn't provide desired results.
// Solution: Add interactivity so the user can manage daily tasks.
let taskInput = document.getElementById('newtask');//new-task
let addButton = document.getElementsByTagName('button')[0]; //first button
let incompleteTasksholder = document.getElementById('incomplete-tasks');
let completedTasksholder = document.getElementById('completed-tasks');
//Add a new task
let addTask = function mything() {
//When the button is pressed
//Create a new list item with the text from #new-task:
let newTask = document.createElement("li");
return newTask;
incompleteTasksholder.appendChild('newTask');
//input (Checkbox)
//label
//input (texts)
//button.edit
//button.delete
//Each elements, need modified and appended
}
3 Answers
Steven Parker
231,271 PointsYou probably didn't mean to put quotes around your variable name newTask.
incompleteTasksholder.appendChild('newTask');
While the variable may contain an Element Node, putting the name in quotes makes it a string literal, which is the wrong type of argument for appendChild.
You should also consider that placing this line after a return statement means that the function will end before it can be executed. I'm not sure how the error would have been shown by the code in the current state. Perhaps you re-ordered the lines after observing the error?
michaelkyllo
11,330 PointsThank you Steve. Can you explain why it doesn't create a new <li>? Nothing happens.
Steven Parker
231,271 PointsIf you remove the quotes and fix the statement order, it does create a new list item. But the item is empty so it will not be visible on the page until some content is added (until then you can see it using the Developer Tools).
Remember to select a "best answer" to indicate the original question is closed.
michaelkyllo
11,330 PointsOnce i put the return statement at the end, it worked. Thank you!!