Created
December 4, 2018 00:55
-
-
Save adamcrampton/e200bca69a70dad8200c8cda765cbc99 to your computer and use it in GitHub Desktop.
Append multiple properties to array, using iteration counter as key within a for loop
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
// Pretend someObject is already defined and populated | |
const someData = {}; | |
for (var i = 0; i < someObject.length; i++) { | |
// Add object data to array. | |
someData[i] = {}; | |
someData[i].itemName = someObject[i].itemName; | |
someData[i].anotherName = someObject[i].anotherName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment