title: Replace value in object
body: <p>I wish to replace some values in my data based on key, I have the below object:</p>
  
  <pre><code>const data = {
    data: {
      config: {
        bioObject: {
          dataBioOne: 1,
          dataBioTwo: "B",
          dataBioThree: "A",
          dataBioFour: 2,
          dataBioFive: 2,
          dataBioSix: 3,
          dataBioSeven: 1
        },
        pinObject: {
          dataPinOne: 5,
          dataPinTwo: "B0",
          dataPinThree: "A0",
          dataPinFour: 6
        },
        appletRegister: [
          {
            aid: "A",
            filterApplet: null,
            bioApplet: false,
            pinApplet: false,
            defaultApplet: true
          },
          {
              aid: "A",
              filterApplet: null,
              bioApplet: false,
              pinApplet: false,
              defaultApplet: true
            },
        ]
      },
      initialization: {
        defaultPin: "1111"
      }
    }
  };
  </code></pre>
  
  <p>And I have two other objects contained in the above object - <code>bioObject</code> and <code>pinObject</code> properties. I wish to loop through the object and replace these two keys and their values with new elements.</p>
  
  <p>My function looks like this:</p>
  
  <pre><code> handleSChange = (bio, pin) =&gt; {
      let dataBio = bio;
      let dataPin = pin;
      let profile = this.state.data;
      console.log(Object.keys(profile.config));
  
      let obj;
      obj = Object.keys(profile.config).forEach((el) =&gt; {
        if (el == "bioObject") {
          el.replace(dataBio)
        }
        if (el == "pinObject") {
          el.replace(dataPin)
        }
      })
      console.log(obj);   
    }
  </code></pre>
  
  <p>But as far as I see I replace only keys, not it's values. If I change keys for values, then I cannot loop through key so won't be able to replace this particular data. Does anyone has any idea how to replace data in these two places?</p>