links.reduce((acc, n) => {
const path = n.url.split('/');
const [ lastFolder ] = path.splice(-2);
(path.reduce((p, c) => p[c] ??= {}, acc)[lastFolder] ??= []).push(n);
return acc;
}, {})
#itemInner {
counter-reset: bullshit-counter;
}
.row {
counter-increment: bullshit-counter;
}
.row::before {
content: counter(bullshit-counter) "!!!";
}
itemInner.find('.item-num').text(i => i + 1);
const selector = '#point';
.const elem = document.querySelector(selector);
const parent = elem?.parentNode;
const elems = [...parent?.children ?? []];
const index = elems.indexOf(elem);
elems.slice(-~index || elems.length).forEach(n => parent.removeChild(n));
// или
for (
const el = document.querySelector(selector);
el?.nextElementSibling;
el.nextElementSibling.remove()
) ;
// или
document.querySelectorAll(`${selector} ~ *`).forEach(n => n.outerHTML = '');
document.querySelector('.shopWrapper').addEventListener('mouseover', function() {
const color = `#${Math.random().toString(16).slice(2, 8).padEnd(6, 0)}`;
this.style.setProperty('--random-color', color);
});
print('\n'.join(f'{k}: {v}' for k, v in collections.Counter(selled).items()))
arr.map(n => {
const ids = Object
.values(n.childrenHash.reduce((acc, m) => ((acc[m.hash] ??= []).push(m.id), acc), {}))
.filter(m => m.length > 1);
return {
...n,
childrenHash: ids.length ? ids : null,
};
})
const table = document.querySelector('здесь селектор вашей таблицы');
const className = 'active';
table.querySelectorAll('tbody td').forEach(td => {
td.classList.toggle(className, !td.textContent.trim());
});
for (const { rows } of table.tBodies) {
for (const { cells } of rows) {
for (const td of cells) {
if (/^\s*$/.test(td.innerText)) {
td.classList.add(className);
}
}
}
}
props: { user: String }, emits: ["update:someUser"]
- emits: ["update:someUser"]
+ emits: ["update:user"]
- @input="$emit('update:someUser', $event.target.value)"
+ @input="$emit('update:user', $event.target.value)"
const sumIntervals = intervals => intervals
.slice()
.sort((a, b) => a[0] - b[0])
.reduce((acc, n) => {
const top = acc.at(-1);
if (!top || top[1] < n[0]) {
acc.push([...n]);
} else if (top[1] < n[1]) {
top[1] = n[1];
}
return acc;
}, [])
.reduce((acc, n) => acc - n[0] + n[1], 0);
const where = '.container';
const what = '.wrapper-item h3';
$(where).prepend(function() {
return $(what, this);
});
document.querySelectorAll(where).forEach(n => {
n.prepend(n.querySelector(what));
});