title: Update the attribute value of an object using the map function in ES6
body: <p>I am trying to code this in ES6. Below is what I am trying to achieve. Let's say I have an array of objects called <code>schools</code>.</p>
  
  <pre><code>let schools = [
      {name: 'YorkTown', country: 'Spain'},
      {name: 'Stanford', country: 'USA'},
      {name: 'Gymnasium Achern', country: 'Germany'}
  ];
  </code></pre>
  
  <p>Now, I want to write a function called <code>editSchoolName</code> which will take 3 parameters, <code>schools</code> (which is the array I have defined above), <code>oldName</code> and <code>name</code>.</p>
  
  <p>I will pass the name of the school in the parameter <code>oldName</code> and that name should be updated with the value in the parameter <code>name</code>. </p>
  
  <p>I don't want to change the state of the variable <code>schools</code> so I am using a <code>map</code> function which will return a new array with the changes.</p>
  
  <p>The <code>editSchoolName</code> function will be called like this -</p>
  
  <pre><code>var updatedSchools = editSchoolName(schools, "YorkTown", "New Gen");
  </code></pre>
  
  <p>Here, the name <code>YorkTown</code> should be replaced with the name <code>New Gen</code>. So the expected value of the array <code>updatedSchools</code> should be -</p>
  
  <pre><code>let updatedSchools = [
      {name: 'New Gen', country: 'Spain'},
      {name: 'Stanford', country: 'USA'},
      {name: 'Gymnasium Achern', country: 'Germany'}
  ];
  </code></pre>
  
  <p>This is how my editSchoolName function looks like -</p>
  
  <pre><code>const editSchoolName = (schools, oldName, name) =&gt;
      schools.map(item =&gt; {
          if (item.name === oldName) {
            /* This is the part where I need the logic */
          } else {
            return item;
          }
      });
  </code></pre>
  
  <p>Need help in making the change in the <code>editSchoolName</code> function to achieve the above mentioned desired result.</p>