Skip to content

Instantly share code, notes, and snippets.

@angelyoung24
Created December 12, 2019 23:48
Show Gist options
  • Save angelyoung24/89bc12a818ee328f1483d7e4a3d344f5 to your computer and use it in GitHub Desktop.
Save angelyoung24/89bc12a818ee328f1483d7e4a3d344f5 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/mizodunuwi
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
const pet = {type: "cat", name: "Mutumbo", age:"5"};
const keys = Object.keys(pet);
const emptyObject = {};
keys.forEach(key => {
const value = pet[key]
emptyObject[value] = key;
});
console.log(emptyObject);
</script>
<script id="jsbin-source-javascript" type="text/javascript">
const pet = {type: "cat", name: "Mutumbo", age:"5"};
const keys = Object.keys(pet);
const emptyObject = {};
keys.forEach(key => {
const value = pet[key]
emptyObject[value] = key;
});
console.log(emptyObject);
</script></body>
</html>
const pet = {type: "cat", name: "Mutumbo", age:"5"};
const keys = Object.keys(pet);
const emptyObject = {};
keys.forEach(key => {
const value = pet[key]
emptyObject[value] = key;
});
console.log(emptyObject);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment