title: JavaScript Map Array
body: <p>array called 'notes' contains 5 objects , each object has keys</p>
  <pre><code>var notes = [
     {
         title: &quot;Home&quot;,
         message: &quot;is a good story&quot;,
         status: 'new',
         author:&quot;dala&quot;,
     },
     {
         title: &quot;School&quot;,
         message: &quot;Have to go everday&quot;,
         status: 'new',
         author:&quot;aisha&quot;,
     },
     {
         title: &quot;study&quot;,
         message: &quot;we have exam to pass&quot;,
         status: 'new',
         author:&quot;Omar&quot;,
     },
     {
         title: &quot;Work&quot;,
         message: &quot;dead line is close&quot;,
         status: 'new',
         author:&quot;Said&quot;,
     },
     {
         title: &quot;homework&quot;,
         message: &quot;as today we need to do it&quot;,
         status: 'new',
         author:&quot;Amal&quot;,
     },
  ];
  </code></pre>
  <p>i want to update all the notes's status to be 'completed',  the error is  the code only update the first Object</p>
  <pre><code>function map(notes,callback){
     const newNotes =[];
     for(var i=0; i&lt;notes.length; i++) {
         const result = callback(notes[i].status = &quot;completed&quot;,i);
         newNotes.push(result);
         return newNotes;
     }
  }
  var outp = map(notes,function(value, i){
     console.log(i)
     for(var a= 0; a&lt;value.length; a++){
         return notes;
  
     }
  
  })
  console.log(outp);
  </code></pre>
  <p>I was training on the callback function, and this training code was the face of a problem writing the code If you have useful resources to learn from, please share them with me</p>