Object.keys(obj).forEach(function (key) { // add the needed keys and their values to the res object }) code example
Example: object keys javascript
const object1 = {
a: 'somestring',
b: 42,
c: false
};
console.log(Object.keys(object1));
// expected output: Array ["a", "b", "c"]