-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinventory.js
More file actions
76 lines (67 loc) · 1.52 KB
/
inventory.js
File metadata and controls
76 lines (67 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const readline = require('readline-sync')
let inventory = [
{
name: "apple",
category: "Fruit",
price: 20,
},
{
name: "shirt",
category: "clothing",
price: 500,
},
{
name: "Book",
category: "Stationery",
price: 150,
},
{
name : "laptop",
category:"eletronic",
price:100000
},
{
name : "Iphone",
category:"eletronic",
price :100000
}
];
// https://github.com/saugat1070
const viewInventory = ()=>{
inventory.map((item)=>{
console.log(item)
})
}
const addInventory = ()=>{
let name = readline.question("Enter name of product:");
let category = readline.question("Enter category of product:");
let price = readline.question("Enter price of product:");
inventory.push({name,category,price});
console.log(`Thank you for adding ${name}`);
}
while(true){
console.log("Welcome to Hamro Dokan");
console.log("1.View All dokan ko saman");
console.log("2. add dokan ko saman");
console.log("3.remove bigreko saman");
console.log("4. filter saman by Category");
console.log("5.Exit")
const choose = readline.question("enter your choice:");
switch(choose){
case "1" : {
viewInventory();
break;
}
case "2":{
addInventory();
break;
}
case "5":{
console.log("Thank you for shopping");
process.exit(0);
}
default:{
console.log("please enter valid chooice")
}
}
}