-
Notifications
You must be signed in to change notification settings - Fork 0
/
random_item_generator.js
170 lines (167 loc) · 2.99 KB
/
random_item_generator.js
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// Variables for item creation
var min = 1;
var max = 25;
// Empty arrays for csv creation
var itemName = [];
var itemReference = [];
var itemUnit = [];
var itemPrice = [];
// Arrays for item creation
var sampleNames = [
"Alfalfa Sprouts",
"Apple",
"Apricot",
"Artichoke",
"Asian Pear",
"Asparagus",
"Atemoya",
"Avocado",
"Bamboo Shoots",
"Banana",
"Bean Sprouts",
"Beans",
"Beets",
"Belgian Endive",
"Bell Peppers",
"Bitter Melon",
"Blackberries",
"Blueberries",
"Bok Choy",
"Boniato",
"Boysenberries",
"Broccoflower",
"Broccoli",
"Brussels Sprouts",
"Cabbage",
"Cactus Pear",
"Cantaloupe",
"Carambola",
"Carrots",
"Casaba Melon",
"Cauliflower",
"Celery",
"Chayote",
"Cherimoya",
"Cherries",
"Coconuts",
"Collard Greens",
"Corn",
"Cranberries",
"Cucumber",
"Dates",
"Dried Plums",
"Eggplant",
"Endive",
"Escarole",
"Feijoa",
"Fennel",
"Figs",
"Garlic",
"Gooseberries",
"Grapefruit",
"Grapes",
"Green Beans",
"Green Onions",
"Greens",
"Guava",
"Hominy",
"Honeydew Melon",
"Horned Melon",
"Iceberg Lettuce",
"Jerusalem Artichoke",
"Jicama",
"Kale",
"Kiwifruit",
"Kohlrabi",
"Kumquat",
"Leeks",
"Lemons",
"Lettuce",
"Lima Beans",
"Limes",
"Longan",
"Loquat",
"Lychee",
"Madarins",
"Malanga",
"Mandarin Oranges",
"Mangos",
"Mulberries",
"Mushrooms",
"Napa",
"Nectarines",
"Okra",
"Onion",
"Oranges",
"Papayas",
"Parsnip",
"Passion Fruit",
"Peaches",
"Pears",
"Peas",
"Peppers",
"Persimmons",
"Pineapple",
"Plantains",
"Plums",
"Pomegranate",
"Potatoes",
"Prickly Pear",
"Prunes",
"Pummelo",
"Pumpkin",
"Quince",
"Radicchio",
"Radishes",
"Raisins",
"Raspberries",
"Red Cabbage",
"Rhubarb",
"Romaine Lettuce",
"Rutabaga",
"Shallots",
"Snow Peas",
"Spinach",
"Sprouts",
"Squash",
"Strawberries",
"String Beans",
"Sweet Potato",
"Tangelo",
"Tangerines",
"Tomatillo",
"Tomato",
"Turnip",
"Ugli Fruit",
"Water Chestnuts",
"Watercress",
"Watermelon",
"Waxed Beans",
"Yams",
"Yellow Squash",
"Yuca/Cassava",
"Zucchini Squash",
];
var sampleUnits = ["Kg", "Case", "Unit", "Piece"];
var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// Random item generation and push to array
for (names of sampleNames) {
itemName.push(sampleNames[Math.floor(Math.random() * sampleNames.length)]);
itemUnit.push(sampleUnits[Math.floor(Math.random() * sampleUnits.length)]);
itemReference.push(
Math.floor(Math.random() * 10000) +
characters.charAt(Math.floor(Math.random() * characters.length))
);
itemPrice.push(Math.floor(Math.random() * (max - min)) + min);
}
console.log(itemName);
console.log(itemUnit);
console.log(itemReference);
console.log(itemPrice);
// Export data to csv
const rows = [["itemName", "itemReference", "itemUnit", "itemPrice"]];
let csvContent = "data:text/csv;charset=utf-8,";
rows.forEach(function (rowArray) {
let row = rowArray.join(",");
csvContent += row + "\r\n";
});