code:
let bar = document.querySelector('.bars'),
navItem = document.querySelector('.nav-items');
bar.addEventListener('click', () => {
navItem.classList.toggle('active');
})
issue:
JsLint:
expected an indentifier and instead saw 'let'. let bar = document.querySelector('.bars'),
ESLint:
ERROR: Parsing error; Unexpected token bar let bar = document.querySelector('.bars'),
ERROR: Parsing error; Unexpected token ) let bar = document.querySelector('.bars'),
so the hamburger menu displays correctly
Whenever you catch yourself wondering if JSLint is operating correctly, I'd suggest trying your code on jslint.com.
This lints there:
There were several things I needed to change to make your code lint, but
letwas not one of them. More ones6and JSLint here.That means, exactly as the commenters have said, that you're seeing this issue because you're not using the latest version of JSLint -- as in you're waaaaay behind. You're at least three years behind, it appears.
You'll need to either push your code back to es5 (
var bar = document.querySelector(".bars");) or update your linter.