I have an array
const arr = ['a', 'b', 'd', 'c', 'e'];
The API sends this data
const data ={a:'a', b:'b', c:'c', e:'e', f:'f'}
sometimes the keys are missing as well but the array keys should always be present in the final result.
the output should be {a:'a', b:'b', d:'', c:'c', e:'e'}. Please help me with ES6 and give me an explanation. I am using reactjs16.9.
In this given case the object d is missing hence it should be initialised with "".
In case If all the keys exist then extra keys from API should be removed.