const wait = delay => new Promise(r => setTimeout(r, delay));async function asyncDelayedForEach(data, callback, delay) {
for (let i = 0; i < data.length;) {
await callback.call(data, data[i], i, data);
if (++i < data.length) {
await wait(delay);
}
}
}const asyncDelayedForEach = (data, callback, delay) =>
Array.prototype.reduce.call(
data,
(promise, n, i, a) => promise
.then(() => callback.call(a, n, i, a))
.then(() => -~i === a.length ? void 0 : wait(delay)),
Promise.resolve()
);
@click="selectCity"selectCity(e, { cityCode, storeId, name }) {$event):@click="selectCity(city)"selectCity({ cityCode, storeId, name }) {
...
Object.values(arr.reduce((acc, [ user, ...data ]) => {
(acc[user] = acc[user] ?? { user, data: [] }).data.push(data);
return acc;
}, {}))
document.querySelector('.todo-app__list').addEventListener('click', e => {
const li = e.target.closest('.todo-app__list-item');
if (li) {
console.log(li.dataset.id);
}
});
18 элементов tbody <...> недопустимо
div внутри tbody
нужно сделать один циклом
state.products, вы передаёте в addBasket его name. Исправьте вызов addBasket; если же там всё так, как и задумано, замените прямое обращение по имени свойства (state.products[action.payload]) на поиск нужного объекта по его name:Object.values(state.products).find(n => n.name === action.payload)
const result = arr1.filter(function(n) {
return this.some(m => m.every(([ k, v ]) => v === n[k]));
}, arr2.map(Object.entries));
to зависящим от текущего маршрута:computed: {
catalogRoute() {
return {
name: 'catalog',
params: {
module: this.$route.name === 'catalog'
? this.$route.params.module.replace(/\d+/, m => +m + 1)
: 'view-1',
},
};
},
},<router-link :to="catalogRoute">
undefined, вместо которого с помощью nullish coalescing подставляем просто цену. А чтобы не копипастить извлечение цены, вынесем его в отдельную функцию, которую, как и сам сортируемый массив, можно сделать параметром функции сортировки.const sorted = (arr, key) => arr
.map(n => [ n, key(n) ])
.sort((a, b) => a[1] - b[1])
.map(n => n[0]);const sortedArr = sorted(arr, n => -(n.price.new ?? n.price).replace(/\D/g, ''));
export const store = new Vuex.Store({ на export default new Vuex.Store({. Или import store from './store'; на import { store } from './store';.
function updateClasses({ $el, slides, activeIndex }) {
$el.find('.swiper-slide-prev-prev').removeClass('swiper-slide-prev-prev');
slides.eq(activeIndex).prev().prev().addClass('swiper-slide-prev-prev');
$el.find('.swiper-slide-next-next').removeClass('swiper-slide-next-next');
slides.eq(activeIndex).next().next().addClass('swiper-slide-next-next');
}on: {
init() {
updateClasses(this);
},
slideChange() {
updateClasses(this);
},
},
vowelsCount = Hash['aeiou'.chars.map{|n| [ n, 0 ]}]
gets.chomp.chars.each{|n| vowelsCount[n] += 1 if vowelsCount.key?(n)}
print(vowelsCount)
const uniqueObj = (obj, key = val => val) =>
Object.fromEntries(Object
.entries(obj)
.filter(function(n) {
const k = key(n[1], n[0]);
return !this.has(k) && this.add(k);
}, new Set)
);
Int(stringValue). Правда, вам это не сильно поможет - есть ещё косяки. Можете попытаться исправить их самостоятельно.func worthSum(count: String, worth: [Int]) -> Int {
return count.split(separator: " ").enumerated().reduce(0, { acc, n in
acc + (Int(n.1) ?? 0) * worth[n.0]
})
}
func evaluate(good: String, vsEvil evil: String) -> String {
let g = worthSum(count: good, worth: [ 1, 2, 3, 3, 4, 10 ])
let e = worthSum(count: evil, worth: [ 1, 2, 2, 2, 3, 5, 10 ])
return g == e
? "Battle Result: No victor on this battle field"
: g > e
? "Battle Result: Good triumphs over Evil"
: "Battle Result: Evil eradicates all trace of Good"
}