Search code examples
javascriptfor-loopjshint

Adding a class to every second item with that has specific class


It works but JShint gives me an error on last line Unexpected '​'. This is why I'm unable to compile using gulp and the whole thing crashes.

var yearData = document.querySelectorAll(".timeline-years .have-data");
for (var i = 0, length = yearData.length; i < length; i++) {
  if (i % 2 == 0) {
    yearData[i].classList.add("bottom-year");
  }
}​

Not sure whats the fatal flaw here?


Solution

  • You have a trailing Zero-width space character on line 5.

    Remove this and your code will run.