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

Traversing and Manipulating the DOM with JavaScript

Uncaught SyntaxError: Unexpected end of input line 140 (last line)

I am trying to test the final pieces of this module I am getting the Error above. That of course causes the script to NOT run, which in turn means I cannot see if anything else is wrong.

The error message is so obscure (to me) that I don't know where to start. Codepen screws up the link every time I give a link so here goes:

http://codepen.io/dhawkinson/pen/rxNprr

1 Answer

Easy mistake. The else statement end curly bracket was backward. See the below correction or my fork of your pen at http://codepen.io/MAustinMMDP/pen/PZoExz

// Edit an existing task
var editTask = function() {
   console.log("Edit Task..."); 

   var listItem = this.parentNode;   
   var editInput = listItem.querySelector("input[type=text");
   var label = listItem.querySelector("label");   
   var containsClass = listItem.classList.contains("editMode"); // true/false

   // if parent's class is .editMode
   if (containsClass) {   
      // switch from .editMode
      // label text becomes the input's value
      label.innerText = editInput.value;
   } else {
      // Switch tp .editMode
      // input value becomes the label's text
      editInput.value = label.innerText;
   }
   // Toggle .editMode on the listItem
   listItem.classList.toggle("editMode");      
}