element.classList returns an array of classes, its my understanding .includes() is used with arrays, so I don\'t understand why this wont work, I k
The reason includes doesn't work is due to classList not being an array, but an array-like object. In this case it is a DOM Token List.
You can convert an array-like object to an array by using the following:
var liClasses = [].slice.apply(li.classList);
or
var liClasses = [...li.classList]; // es2015 syntax
Otherwise, .includes() should be .contains(). See https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
li.classList.contains('main-nav')
contains( String )
Checks if specified class value exists in class attribute of the element.