Currently, I am attempting to create a method that will allow me to add an element to my array. Despite being new to typescript, I have been struggling to determine what needs to go into the addNewProduct function. While seeking help, I came across the push function, but when implemented, it gives an error message stating "not applicable on type {}".
class ProductsComponent {
title = 'Products List';
products: any[] = [
{
'name': 'a',
'quantity': 20
},
{
'name': 'b',
'quantity': 200
}
];
constructor(){
// Printing the current Product Array
this.addNewProduct('c', 50 );
// Printing the new Array
}
addNewProduct(name: string, quantity: number) {
// Code for adding a new product
}
}