Currently receiving an undefined error when attempting to assign property values to a collection of objects.
Code:
MyArray = [];
for(let j=0; j<5; j++) {
MyArray[j].randoAttribute = 2;
MyArray[j].anotherRandoAttrbute = 3;
}
Error message:
TypeError: Cannot set properties of undefined (setting 'randoAttribute')
Goal: How do I avoid this error and still be able to dynamically assign property values in an iterator?