I want to populate orders which is an array of type Order. The expected result is orders=[{id:1,qt:4},{id:2, qt:2},{id:3,qt:2}]. How to do so in TypeScript? I am new to it.
export class Product {
  constructor(public id: number, public name: string, public price: number) {}
}
export interface Order {
  id: number;
  qt: number;
}
export const products: Product[] = [
  new Product(1, 'Apple', 2.1),
  new Product(2, 'Banana', 2.2),
  new Product(3, 'Chocolate', 2.3),
  new Product(4, 'Dessert', 2.4),
];
export const cart: Product[] = [
  products[0],
  products[0],
  products[2],
  products[1],
  products[2],
  products[0],
  products[1],
  products[0],
];
export const orders: Order[] = [];
Edit
For those who want to know how
orders=[{id:1,qt:4},{id:2, qt:2},{id:3,qt:2}] is obtained.
In the cart:
- the quantity of apples (id:1) isqt:4
- the quantity of bananas (id:2) isqt:2
- the quantity of chocolates (id:3) isqt:2
So by using cart, I have to obtain orders=[{id:1,qt:4},{id:2, qt:2},{id:3,qt:2}]. It should be clear.
 
     
    