export function task1() {
interface Order {
customerId: string;
amount: number;
status: "pending" | "completed";
}
const orders: Order[] = [
{ customerId: "A", amount: 100, status: "completed" },
{ customerId: "B", amount: 200, status: "completed" },
{ customerId: "A", amount: 50, status: "completed" },
{ customerId: "C", amount: 300, status: "pending" },
{ customerId: "B", amount: 50, status: "pending" }
];
// Функция должна вернуть массив customerId (в порядке убывания суммы всех заказов),
// содержащий не более topN клиентов, у которых есть хотя бы один завершенный заказ
function getTopCustomers(orders: Order[], topN: number): string[] {
}
const result = getTopCustomers(orders, 2);
console.log(result);
}
Click Run to execute JavaScript.
Code runs in an isolated environment.
Code runs in an isolated environment.