Insert element inside array

I have a function

checkName(output) {

  output.filter((NewData) => {
    return this.props.elements.filter((OldData) => {
      if (NewData.key == OldData.key) { =,
          //there i need to add another element 
          // Need to add newData.number = OldData.number
      return NewData
  return output

and I call this function like:

const named = this.checkName(product.rows)

Now I need to add to my product’s array that I passed to checkName the value "OldData.Number" to "newData.Number" that is not defined in product (so I need to create this field)

For example:

Product before the checkName function

product.rows = []

Product after the checkName function

product.rows = ["value of", NewData.number="value of OldData.number"]

How can I obtain this result?

36 thoughts on “Insert element inside array”

Leave a Comment