const steps = Object.entries(answers).reduce((acc, [ key, val ]) => {
const question = questions.find(n => n.key === key);
const step = acc[val.step] = acc[val.step] || [];
step.push({
step: val.step,
question: { ...question.question },
answer: question.answer.values instanceof Object
? question.answer.values[val.answer].en
: val.answer,
});
return acc;
}, {});
const arr = JSON.parse(localStorage.getItem('arr')) || [];
arr.push(1, 2, 3);
localStorage.setItem('arr', JSON.stringify(arr));
const lowered = str.toLowerCase();
const filtered = [];
for (const n of data) {
if (!n.name.toLowerCase().indexOf(lowered)) {
filtered.push(n);
}
}const filtered = data.filter(function(n) {
return n.name.toLowerCase().startsWith(this);
}, str.toLowerCase());const filtered = (function get(reg, i, n = data[i]) {
return n
? [].concat(reg.test(n.name) ? n : [], get(reg, -~i))
: [];
})(RegExp(`^${str}`, 'i'), 0);
чтобы числа повторялись не более двух раз
SELECT *, price * ((100 - discount) / 100) AS discounted
FROM prices
ORDER BY discounted
LIMIT 10
$(document).on({
focus() {
$(this).addClass('active-amount-input');
},
blur() {
$(this).removeClass('active-amount-input');
},
}, '.amount, .amount_1');$(document).on('focusin focusout', '.amount, .amount_1', e => {
$(e.currentTarget).toggleClass('active-amount-input', e.type === 'focusin');
});
- <main className={active ? 'move-to-left' : ''}>
+ <main>- <div className="sidebar">
+ <div className={'sidebar ' + (active ? 'move-to-left' : '')}>- <NavRight onClick={this.toggleActive} buttonClass={!active ? 'active' : ''} navClass="hidden-xs" />
+ <NavRight onClick={this.toggleActive} buttonClass={active ? 'active move-to-left' : ''} navClass="hidden-xs" />+ body {
+ overflow: hidden;
+ }.sidebar {
...
- z-index: 1;
- right: 0;
+ z-index: 3;
+ right: -400px;
+ transition: all .7s ease;Имелось в виду, что контент тоже двигается при смещении sidebar, но не убегает полностью в левый угол, а остается по центрy оставшейся ширины
TS2362 The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum
this.endDate - this.currentDate+this.endDate - +this.currentDate
const unique = (arr, keys) =>
arr.filter((n, i, a) => i === a.findIndex(m => keys.every(k => n[k] === m[k])));const pick = (obj, keys) =>
keys.reduce((acc, k) => (acc[k] = obj[k], acc), {});const keys = [ 'type', 'date' ];
const uniqueDocs = unique(docs, keys).map(n => pick(n, keys));