async function asyncFilter(array, asyncCallback) {
const results = await Promise.all(
array.map(async (item, index, arr) => asyncCallback(item, index, arr))
);
 
return array.filter((_, index) => results[index]);
}
 
 
const isEvenAsync = async (num) => {
await new Promise((r) => setTimeout(r, 100));
return num % 2 === 0;
};
 
asyncFilter([1, 2, 3, 4, 5], isEvenAsync).then(console.log);
console.log(asyncFilter([1, 2, 3, 4, 5], isEvenAsync))
 
// [2, 4]
 
 
// Написать функцию asyncFilter, который принимает массив и асинхронный колбэк,
// а возвращает промис с отфильтрованным массивом
Code will run automatically after changes.
Code runs in an isolated environment.