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 Interactive Web Pages with JavaScript Traversing and Manipulating the DOM with JavaScript Perform: Traversing Elements with querySelector

Console log is telling me... Uncaught SyntaxError: Unexpected token. Not sure what that means.

Not sure what I'm doing wrong

//Problem: User interaction doesn't provide desired results //Solution: Add interactivity so the user can manage daily task

var taskInput = document.getElementById("new-task"); //new-task var addButton = document.getElementsByTagName("buttton")[0]; //first button var incompleteTasksHolder = document.getElementById("incomplete-task"); //incomplete-tasks var completedTasksHolder = document.getElementById("completed-task"); //completed-tasks

//Add a new task var addTask = function () { console.log("Add task..."); //When the button is pressed

//Create a new list iten with the text from #new-task //input checkbox //label //input (text) //button.edit //button.delete //Each element, needs modify and appended }

//Edit an existing task var editTask = function { console.log("Edit task..."); //When the edit button is pressed //if the class of the parent is .editMode //Switch from .editMode //label text become the input's value //else //Switch to .editMode //input value becomes the label's text

//Toggle .editMode on the parent

}

//Delete a existing task var deleteTask = function(){ console.log("Delete task..."); //When the Delete button is pressed //Remove the parent list item from the ul }

//Mark a task as complete var taskCompleted = function() { console.log("task complete..."); //When the checkbox is checked //Append the task list item to the #completed-tasks }

//Mark a task as incomplete var taskIncomplete = function() { console.log("task incomplete..."); //When the ckeckbox is unchecked //Append the task list item to the #incompleted-tasks }

var bindTaskEvents = function(taskListITem, checkBoxEventHandler) { console.log("Bind list items events"); //select taskListItem's children var checkbox = taskListITem.querySelector("input[type=checkbox]"); var editButton = taskListITem.querySelector("button.edit"); var deleteButton = taskListITem.querySelector("button.delete");

//bind editTask to edit button editButton.onclick = editTask;

//bind deleteTask to delete button deleteButton.onclick = deleteTask;

//bind taskCompleted to checkbox checkbox.onchange = checkBoxEventHandler; }

//Set the click handler to the addTask function addButton.onclick = addTask;

//cylce over incompleteTasksHolder ul list items for(var i = 0; i < incompleteTasksHolder.children.length; 1++) { //bind events to list item's children (taskCompleted) bindTaskEvents(incompleteTasksHolder.children[i], taskCompleted); } //cylce over completedTasksHolder ul list items for(var i = 0; i < completedTasksHolder.children.length; 1++) { //bind events to list item's children (taskIncomplete) bindTaskEvents(completedTasksHolder.children[i], taskIncomplete); }

1 Answer

Martin Cornejo Saavedra
Martin Cornejo Saavedra
18,132 Points

Check the line in which the error appears, the console tells the line where the error was caught. Token error is frequently a missing or extra bracket { or } or parentheses ). The code you pasted is not well orderer, so it's hard to check by viewing.