const getMinimumUniqueSum = arr => [...arr]
.sort((a, b) => a - b)
.reduce((acc, n) => (acc[1] += acc[0] = Math.max(acc[0] + 1, n), acc), [ -Infinity, 0 ])
.pop();
const find = (arr, id) =>
(Array.isArray(arr) ? arr : []).reduce((found, n) =>
found || (n.id === id ? n : find(n.replies, id))
, null);
data: () => ({
opened: false,
}),
<div class="dropdown">
<div class="dropdown-header" @click="opened = !opened">
<slot name="header" :opened="opened">
{{ opened ? 'CLOSE' : 'OPEN' }}
</slot>
</div>
<div v-if="opened" class="dropdown-content">
<slot name="content"></slot>
</div>
</div>
IndexError: string index out of range
+ 1
делать.print([ chr(i + 96) * i for i in range(1, 27) ])
button с классами .tool и .название цвета
let color = '#000';
document.querySelector('селектор контейнера с кнопками').addEventListener('click', e => {
if (e.target.classList.contains('tool')) {
color = e.target.dataset.color;
}
});
document.querySelector('селектор контейнера с "пикселями"').addEventListener('click', e => {
if (e.target.classList.contains('pixel')) {
e.target.style.backgroundColor = color;
}
});
filterBox.forEach(n => {
n.classList.toggle('none', ![ 'all', n.dataset.work ].includes(filterBtn));
});
const container = document.querySelector('.side__nav');
const itemSelector = 'li';
const activeClass = 'is-active';
container.addEventListener('click', function(e) {
const item = e.target.closest(itemSelector);
if (item) {
this.querySelector(`${itemSelector}.${activeClass}`)?.classList.remove(activeClass);
item.classList.add(activeClass);
}
});
const items = container.querySelectorAll(itemSelector);
const onClick = e => items.forEach(n => n.classList.toggle(activeClass, n === e.currentTarget));
items.forEach(n => n.addEventListener('click', onClick));
const element = document.querySelector(`.js-filter-wrap a[data-filter="${конкретноеЗначение}"]`);
if (element) {
...
const element = [...elements].find(n => n.dataset.filter === конкретноеЗначение);
if (element) {
...
options: {
scales: {
yAxes: [
{ id: 'y1', position: 'left' },
{ id: 'y2', position: 'right' },
],
},
},
приложение делается на vue
<script src="script.js" />
In HTML, the use of this syntax is restricted to void elements and foreign elements. If it is used for other elements, it is treated as a start tag.
@click="$store.commit('setCoords', marker.coords)"
. Internal methods and internal slots are identified within this specification using names enclosed in double square brackets...
Within this specification a well-known symbol is referred to by using a notation of the form @@name...
Within this specification a reference such as %name% means the intrinsic object...
let displayMessage = ''; doItems.forEach((item, i) => { displayMessage += ` <li class="do__item"> <input type="checkbox" id="do_${i}" ${item.checked ? 'checked': ' '}> <label for="do_${i}" class="${item.checked ? 'checked' : ' '}">${item.message}</label> <button class="remove" id="do_${i}">Delete</button> </li>`; block.innerHTML = displayMessage; });