Let's say that I'm doing this because of my homework. I would like to develop some kind of schedule for the week to come (array of 6-7 elements - output result). But I have one problem. I need to figure it out how one element be positioned in the array and also his frequency must be exactly what user input is. Elements must be positioned at different index in the array.
I'm having that kind of input from user (just an example);
var arrayOfElements = ["el1","el2","el3"]; var el1Frequency = 3; var el2Frequency = 2; var el3Frequency = 1; //output array of schedule (this is just an example) var finaloutPutArray = ["el1","el2","el3","el1","el2","el1"]; Index of elements el1 is 0, 3 and 5, basically, I don't want elements to be repeated like this;
["el1","el1","el2","el3"...]; ["el2","el1","el1","el3"]; Can you please give me some ideas on how to solve this problem.
I started like this;
var finalSchedule = []; var totalDaysPerWeek = 6; for(var i =0; i < totalDaysPerWeek; i++) { ... }