Skip to content

Instantly share code, notes, and snippets.

@LokeshSagi
Created July 6, 2020 05:20
Show Gist options
  • Save LokeshSagi/abc7e7f468aaf0857bfb1ce66fa5d614 to your computer and use it in GitHub Desktop.
Save LokeshSagi/abc7e7f468aaf0857bfb1ce66fa5d614 to your computer and use it in GitHub Desktop.
export function reverseTheObject(obj) {
return objReverse(obj);
}
objReverse(object) {
var newObject = {};
var keys = [];
for (var key in object) {
keys.push(key);
}
for (var i = keys.length - 1; i >= 0; i--) {
var value = object[keys[i]];
newObject[keys[i]] = value;
}
return newObject;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment