1.0.1 • Published 3 years ago

warehouse_data_products v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Description

A warehouse has collected the data of N products, for this they are entered in a repetitive process: the type (food, clothing), the origin (National, Imported) and the price of each product. Build an algorithm that allows you to calculate the following: • The average prices of products of National origin • The average prices of imported products. • The lowest price • The quantity of products of the type Food • The quantity of products of the Dress type.

Usage

let Product=require("./Product").Product;
let Warehouse=require("./Warehouse").Warehouse;

let arrayproducts=[];
 arrayproducts.push(new Product("Food","National",10));
 arrayproducts.push(new Product("Dress","National",8));
 arrayproducts.push(new Product("Food","Imported",5));
 arrayproducts.push(new Product("Dress","Imported",6));
 arrayproducts.push(new Product("Dress","Imported",7));
 arrayproducts.push(new Product("Food","National",11));
 arrayproducts.push(new Product("Dress","Imported",12));
 arrayproducts.push(new Product("Food","National",13));
 arrayproducts.push(new Product("Food","National",9));
 arrayproducts.push(new Product("Food","National",11));
 arrayproducts.push(new Product("Dress","Imported",12));
 arrayproducts.push(new Product("Food","National",13));

 let warehouse=new Warehouse(arrayproducts);
 let calc=warehouse.average();
 console.log("The average prices of products of national origin is: USD "+calc.averagenational);
 console.log("The average prices of products of imported origin is: USD "+calc.averageimported);
 console.log("The lowest price is : USD "+calc.lessprice);
 console.log("The quantity of products of the type Food is: "+calc.food);
 console.log("The quantity of products of the type Dress is: "+calc.dresses);