return a.width - b.width
const List = ({ items }) => {
const [ active, setActive ] = React.useState(null);
function onClick(e) {
const index = +e.target.dataset.index;
setActive(active === index ? null : index);
}
return (
<ul>
{items.map((n, i) => (
<li key={n.id}>
<span data-index={i} onClick={onClick}>{n.id}</span>
{active === i ? <div>{n.link}</div> : null}
</li>
))}
</ul>
)
};
const List = ({ items }) => {
const [ active, setActive ] = React.useState({});
const onClick = ({ target: { dataset: { index } } }) =>
setActive(active => ({ ...active, [index]: !active[index] }));
return (
<ul>
{items.map((n, i) => (
<li key={n.id}>
<span data-index={i} onClick={onClick}>{n.id}</span>
{active[i] ? <div>{n.link}</div> : null}
</li>
))}
</ul>
)
};
function duplicateEncode(str) {
const arr = [...str.toLowerCase()];
const count = arr.reduce((acc, n) => (acc[n] = (acc[n] || 0) + 1, acc), {});
return arr.map(n => count[n] > 1 ? ')' : '(').join('');
}
function duplicateEncode(str) {
const arr = str.toLowerCase().split('');
const duplicates = arr.reduce((acc, n) => (acc[n] = acc.hasOwnProperty(n), acc), {});
return ''.concat(...arr.map(n => '()'[+duplicates[n]]));
}
const duplicateEncode = str => Object
.values(Object
.values(str.toLowerCase())
.reduce((acc, n, i) => ((acc[n] = acc[n] || []).push(i), acc), {}))
.reduce((acc, n) => (n.forEach(i => acc[i] = n.length > 1 ? ')' : '('), acc), [])
.join``;
const duplicateEncode = str => Array
.from(str.toLowerCase())
.reduce((acc, n, i, a) => acc + (a.indexOf(n) === a.lastIndexOf(n) ? '(' : ')'), '');
const duplicateEncode = str => str
.toLowerCase()
.replace(/./g, (m, _, s) => String.fromCharCode(40 + (s.split(m).length > 2)));
const countUniqueChars = str =>
new Set(str).size;
const countUniqueChars = str => [...str]
.reduce((acc, n) => (acc.includes(n) || acc.push(n), acc), [])
.length;
const countUniqueChars = str => Array
.from(str)
.reduce((acc, n, i, a) => acc + (i === a.indexOf(n)), 0);
const countUniqueChars = str => Object
.keys(Object.fromEntries([].map.call(str, n => [ n, 1 ])))
.length;
const countUniqueChars = str => str
.split('')
.sort()
.filter((n, i, a) => n !== a[i - 1])
.length;
const countUniqueChars = str =>
(str && str.match(/(.)(?!.*\1)/g)).length;
index.js
меняете value={bookStoreService} data={data}
на value={{ bookStoreService, data }}
, а в with-bookstore-service.js
меняете (bookStoreService, data)
на ({ bookStoreService, data })
. <div class="xxx">hello, world!!</div>
<div class="xxx">fuck the world</div>
<div class="xxx">fuck everything</div>
.xxx {
padding: 10px;
margin: 10px;
border: 1px solid silver;
}
let el = null;
document.addEventListener('mousedown', e => el = e.target.closest('.xxx'));
document.addEventListener('mouseup', e => el = null);
document.addEventListener('mousemove', e => {
if (el) {
const height = parseInt(getComputedStyle(el).height);
el.style.height = `${height + e.movementY}px`;
}
});
const { id } = Object.values(CategoryProduct).flat().find(n => n.name === name) || {};
const selector = 'li.my_class a[href="#"]';
.document.querySelectorAll(selector).forEach(function(n) {
n.addEventListener('click', this);
}, e => e.preventDefault());
document.addEventListener('click', e => {
const link = e.target.closest(selector);
if (link) {
e.preventDefault();
}
});
Не могу понять, что в моём коде не так.
function getIndexOfWarmestDay(data){
let max = 0;
resultArr += max;
max = 0;
console.log(resultArr);
console.log
тут надо делать return
.data.map(n => Math.max(...n))
.return createElement('div', {
domProps: {
innerHTML: '<b>hello, world!!</b>',
},
});