0

Hi I am trying to perform a loop, through an array of objects and perform a find and replace for each property. Below is an example of what each object looks like and the for statement that is giving me trouble

specialAdsArray.push({dogID:[dataRange[i][0],"[dogID]"], 
              dogName:[dataRange[i][1],"[dogName]"] 
              })



  for (var prop in specialAdsArray[i]) {
    if (specialAdsArray[i].hasOwnProperty(prop)) {
      adPiecesArrayCopy[j]=  adPiecesArrayCopy[j].content.replace(adPiecesArrayCopy[i].prop[0],adPiecesArrayCopy[i].prop[1])
 }
}

Once I get to this step though where I actually go through to do the actual find and replace. The variable prop is not acting as the array I thought it would represent. and I'm getting: "

TypeError: Cannot read property "0" from undefined. (line 89, file "Try 3")

How do I access theses sub-arrays that are assigned to each property.

Jake B
  • 1
  • 1

0 Answers0