Last active
April 2, 2019 00:00
-
-
Save rdeprey/d25875373f5f05a580761901026dea14 to your computer and use it in GitHub Desktop.
Converting an object to an array using a for... in loop
This file contains 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
const taco = { | |
tortillaType: 'corn', | |
meat: 'chicken', | |
toppings: 'lettuce, cheese, tomatoes', | |
}; | |
const tacoArr = []; | |
for (value in taco) { | |
tacoArr.push([value, taco[value]]); | |
} | |
console.log(tacoArr); // expected output: [['tortillaType', 'corn'], ['meat', 'chicken'], ['toppings', 'lettuce, cheese, tomatoes']] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment