This is what i have so far. Basically every time i make a new Item object i need it to create a specific number of another object called Sensor. I've tried a few other methods and none seem to way the work that i need.
function Item (id,number,operator,numOfSensors){
this.id = id;
this.number = number;
this.operator = operator;
this.numOfSensors = numOfSensors;
var sensor = new Sensor[numOfSensors];
}
var Sensor = {
timeStamp:[],
itemPassed: function(){
timeStamp.push(Date.now());
}
}
Thanks so much for any help :) i'm a bit new to js EDIT:
Hey guys! Thanks for the help. Basically my issue is neatly making an array of Objects. In the item object i want to make a [numOfSensors] amount of the Sensor object. I cant seem to find a way to do that. SO i guess my question is how would i go about creating an array of objects with a set number of elements?