I am trying to print individual values from an array but it doesn't seem to work (get undefined). When i print out the array itself it shows that values are contained in the array at index 0 and 1.
let imgDim = [];
imgDim.push(300);
imgDim.push(300);
let width = imgDim[0];
let height = imgDim[1];
let testString = "s994320";
if (/^[ms]\d+$/.test(testString) == true) {
console.log(imgDim); //works
console.log(width, height); //undefined undefined
}