// fist one:
function taxCalculation1( options: TaxCalcualtionOptions ):number[] {
let total = 0;
options.products.forEach( product => {
total += product.price;
})
return [total, total * options.tax];
}
// second one:
function taxCalculation2( options: TaxCalcualtionOptions ):number[] {
let total = 0;
options.products.forEach( ({ price }) => {
total += price;
})
return [total, total * options.tax];
}
// third one:
function taxCalculation3( {tax, products}: TaxCalcualtionOptions ):[number, number] {
let total = 0;
products.forEach( ({ price }) => {
total += price;
})
return [total, total * tax];
}
// fourth one:
function taxCalculation4( options: TaxCalcualtionOptions ):[number, number] {
const { tax, products } = options;
let total = 0;
products.forEach( ({price}) => {
total += price;
})
return [total, total * tax];
}