I have a demo here https://stackblitz.com/edit/angular-w7vavy
I'm trying to create a function that will generate an array of objects that contain random numbers an then output the array on the screen
I just getting an error - Error: Cannot set property '0' of undefined
createData = () => { for(let n=0; n<=this.dates.length;n++){ for(let i= 0; i<=4; i++){ this.testData[i] = { data_1: Math.random() * (this.max - this.min), data_2: Math.random() * (this.max - this.min), data_3: Math.random() * (this.max - this.min), data_4: Math.random() * (this.max - this.min), date: this.dates[i] } } } }