Created
July 6, 2020 05:20
-
-
Save LokeshSagi/abc7e7f468aaf0857bfb1ce66fa5d614 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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