In my opinion, instead of using the traditional if-else statements to switch CSS classes, using a conditional operator in conjunction with modClass
makes the code simpler, easier to read and saves on code lines.
Instead of doing the traditional way:
if (i < 5) {
jQuery('ul').removeClass('many-items');
} else {
jQuery('ul').addClass('many-items');
}
We simply use:
jQuery('ul').modClass(i < 5 ? 'remove' : 'add', 'many-items');
Hope this is useful. Thanks!