0

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?

Tyler Roper
  • 21,445
  • 6
  • 33
  • 56
MasterNone
  • 558
  • 1
  • 5
  • 20
  • 1
    When I copy + paste your code into JSFiddle, there's an invalid `\u200b` character after the last `}`. Perhaps this is related: [\u200b (Zero width space) characters in my JS code. Where did they come from?](https://stackoverflow.com/questions/7055600/u200b-zero-width-space-characters-in-my-js-code-where-did-they-come-from) – Tyler Roper Mar 01 '19 at 15:37
  • Btw, you can probably do this [just with CSS only](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child) – Bergi Mar 01 '19 at 15:54
  • @Bergi it doesnt contain only .have-datas, it has elements without the class so needs to skip those. – MasterNone Mar 01 '19 at 16:04

1 Answers1

1

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

Remove this and your code will run.

Ozzy Walsh
  • 877
  • 9
  • 17
  • 2
    I feel like rather than an answer, this situation warrants more of a "comment and close as *typo*". Just for future reference. – Tyler Roper Mar 01 '19 at 15:41