const SHOW_MORE = 3;
const itemSelector = '.item';
const hiddenClass = 'd-none';
const hiddenSelector = `.${hiddenClass}`;
const $show = $('.show');
const $hide = $('.hide');
const $items = $(itemSelector);
function updateButtons() {
$show.toggleClass(hiddenClass, $items.filter(hiddenSelector).length === 0);
$hide.toggleClass(hiddenClass, $items.not(hiddenSelector).length === SHOW_MORE);
}
$show.click(function() {
$items.filter(hiddenSelector).slice(0, SHOW_MORE).removeClass(hiddenClass);
updateButtons();
}).click();
$hide.click(function() {
$items.slice(SHOW_MORE).addClass(hiddenClass);
updateButtons();
});