Create an Array of Objects for Patch Notes in React I was looking to get some reviews of my code, so I can improve my writing. Functionally it works the exact way I want it to based on my patch notes .md file. I'm open to all suggestions for improving the code, especially in making it more performant.



 state = {
  open: false,
  notes: null
 }

 componentDidMount() {
  this.getData();
 }

 getData = () =&gt; {
  axios.get(patchnotes_md_urlpath)
   .then((response) =&gt; {
    const updates = response.data.replace(/(\r\n|\n|\r)/g, '').split('### ');
    let i;
    let j;
    let notes = [];
    for ( i = 1; i &lt; updates.length; i++ ) {
     let update = updates[i].split('* ');
     const newObj = Object.assign({});
     newObj.version = update[0];
     let list = [];
     for ( j = 1; j &lt; update.length; j++ ) {
      list.push(update[j]);
     }
     newObj.notes = list;
     notes.push(newObj);
    }
    this.setState({
     notes
    });
   }).catch((error) =&gt; {
    console.error(error);
   });
 }






### 0.1.2

* Patch notes now implemented when the modal starts.
* Added top lists for organizations

### 0.0.1

* Patch Notes Added
* Modal to include Patch Notes
You got the first step right by removing every white space and line breaks from your string. Next you will have to remove the first occurence of ### by splitting your string and then slicing out the first element.

When done, you will have to map the result of your split. Map will create a new array the exact same size of your input and apply the same function on every attribute of it.

You will then have to split each update by the *. When done, you can get the first value of your array with shift. This function will give out the first element of your array and delete it from the array, only leaving the notes that are going to be put in the notes variable :



const data = '### 0.1.2\n* Patch notes now implemented when the modal starts.\n* Added top lists for organizations\n### 0.0.1\n* Patch Notes Added\n* Modal to include Patch Notes'

const updates = data.replace(/(\r\n|\n|\r)/g, '').split('### ').slice(1).map(update =&gt; {
 updateData = update.split('* ')
 return {
  version: updateData.shift(),
  notes: updateData
 }
})

console.log(updates)




You can then put this function in the .then of your axios call