I have an array that I am looping through and assigning an integer to my variable based off the condition. I would then like to push this variable to my existing array. At the moment, when pushing it is creating a new index. I would like the variable to be included in the existing index of the array. Here is an example of my code:
let data = [{
  "title": "Online",
  "state": "California"
}, {
  "title": "Retail",
  "state": "New York"
}, {
  "title": "Appointments",
  "state": "Florida"
}]
let varInt = 0;
let intArr = []
for (let i = 0; i < data.length; i++) {
  if (data[i].title && data[i].title.includes("Online")) {
    varInt = 1;
    intArr = {
      "varInt": varInt
    }
    data.push(intArr)
    console.log(data)
  }
}My expected outcome is to have an array that looks like:
data = [{
  "title": "Online",
  "state": "California",
  "varInt": 1
}, {
  "title": "Retail",
  "state": "New York"
}, {
  "title": "Appointments",
  "state": "Florida"
}]
 
     
     
    