Доброе утро! Помогите разобраться с такой задачей. Задача сделать 100 фактур. На данный момент сделал это. На данный момент нужно чтобы из массива в каждую фактуру добавлялись по 10 товаров далее для этих товаров из массивов должны добавляться стоимость, количество и т.п
function randomDate(date1, date2) {
function randomValueBetween(min, max) {
return Math.random() * (max - min) + min;
}
var date1 = date1 || '01-01-2017'
var date2 = date2 || new Date().toLocaleDateString()
date1 = new Date(date1).getTime()
date2 = new Date(date2).getTime()
if (date1 > date2) {
return new Date(randomValueBetween(date2, date1)).toLocaleDateString()
} else {
return new Date(randomValueBetween(date1, date2)).toLocaleDateString()
}
}
var fakturaN = [];
for (var i = 1; i <= 100; i++) {
fakturaN.push(i);
}
var sellern = "Dogserf";
var sellernip = "2254913384";
var selleradr = "2592 Davis Place";
var sellerpost = "87918997";
var selleracc = "85090922712148335820";
var firmString="Justsurf,DietyElephant,MetaHound,CuteOx,SweetFrank,PonyMice,BoarsAndInu,KrazyRat,GlumCats,ManedPie,ZipperPuppy,AKCStew,FoxFlock,NerdyLion,SnipeSkull,KittenFur,SilentRabbit,Pupski,BearSide,Mouse17C";
var firms = firmString.split(",");
var repeated = [].concat(... new Array(100).fill(["Justsurf", "DietyElephant", "MetaHound","CuteOx","SweetFrank","PonyMice","BoarsAndInu","KrazyRat","GlumCats","ManedPie","ZipperPuppy","AKCStew","FoxFlock","NerdyLion","SnipeSkull","KittenFur","SilentRabbit","Pupski","BearSide","Mouse17C"]))
var adressString="3118 Palmer Road,4996 Watson Lane,504 Hawks Nest Lane,3432 Glory Road,157 Crosswind Drive,3063 New York Avenue,997 Jadewood Drive,1630 Mulberry Lane,1710 Jehovah Drive,409 Monroe Street,3538 Hickman Street,68 Powder House Road,2449 Eagle Drive,1143 Collins Avenue,2848 Snyder Avenue,3797 Willis Avenue,4008 Alexander Avenue,3406 Wines Lane,1610 Gorby Lane";
var adress = adressString.split(",");
var repeated1 = [].concat(... new Array(100).fill(["3118 Palmer Road", "4996 Watson Lane", "Hawks Nest Lane","3432 Glory Road","157 Crosswind Drive","3063 New York Avenue","997 Jadewood Drive","1630 Mulberry Lane","1710 Jehovah Drive","409 Monroe Street","3538 Hickman Street","68 Powder House Road","2449 Eagle Drive","1143 Collins Avenue","2848 Snyder Avenue","3797 Willis Avenue","4008 Alexander Avenue","3406 Wines Lane","1610 Gorby Lane","2449 Eagle Drive"]))
var postGen = function(len) {
var arr=new Array();
for (var j=0;j<len;j++){
arr.push(Math.floor(Math.random()*10));
}
return arr.join("");
};
var accountGen = function(len) {
var arr=new Array();
for (var j=0;j<len;j++){
arr.push(Math.floor(Math.random()*10));
}
return arr.join("");
};
var vegString=["Apple","Apricots","Avocado","Banana","Blackberries"];
var randomAnswer = vegString[Math.floor(Math.random() * vegString.length)];
var bases = [];
for (var i = 0; i < fakturaN.length; i++)
{
var base = new Object();
base.pref = fakturaN[i];
base.sellern = sellern;
base.sellernip = sellernip;
base.selleradr = selleradr;
base.sellerpost = sellerpost;
base.selleracc = selleracc;
base.repeated = repeated[i];
base.repeated1 = repeated1[i];
base.account=accountGen(20);
base.postal=postGen(8);
base.fullname=randomAnswer;
bases.push(base);
}
for (var k = 0; k < bases.length; k++)
{
console.log("№ FAKTURY 000" + bases[k].pref + " " + " ---------------------------------------------------------------------------------------------------------- " + " " + randomDate() + "\n" + "SELLER: " + base.sellern + " " + "NIP: " + base.sellernip + " " + "ADRESS: " + base.selleradr + " " + "ACCOUNT: " + base.selleracc + " " + "POSTAL: " + base.sellerpost + "\n" + "CUSTOMER: " + bases[k].repeated+ " ADRESS: " + bases[k].repeated1+" ACCOUNT№ "+": "+bases[k].account+" POSTAL "+": "+ bases[k].postal+ "\n"+"Produkt "+k+1+": "+bases[k].fullname+ "\n"+"Produkt "+k+5+": "+bases[k].fullname);
}