Created
September 26, 2018 16:57
-
-
Save mactanxin/ad2721c0941126918b1a61cf5b9b732c to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/tugesihala
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
<!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"> | |
var obj = { | |
"a": "char", | |
"b": "char", | |
"c": "char", | |
"1": "num", | |
"2": "num", | |
"3": "num" | |
} | |
console.log(2) | |
function invert(obj){ | |
var result = {}; | |
for(var i in obj){ | |
let result_key = obj[i]; | |
if(!result[result_key]){ | |
result[result_key]= []; | |
} | |
result[result_key].push(i) | |
} | |
return result; | |
} | |
var ss = invert(obj); | |
console.log(ss) | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var obj = { | |
"a": "char", | |
"b": "char", | |
"c": "char", | |
"1": "num", | |
"2": "num", | |
"3": "num" | |
} | |
console.log(2) | |
function invert(obj){ | |
var result = {}; | |
for(var i in obj){ | |
let result_key = obj[i]; | |
if(!result[result_key]){ | |
result[result_key]= []; | |
} | |
result[result_key].push(i) | |
} | |
return result; | |
} | |
var ss = invert(obj); | |
console.log(ss)</script></body> | |
</html> |
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
var obj = { | |
"a": "char", | |
"b": "char", | |
"c": "char", | |
"1": "num", | |
"2": "num", | |
"3": "num" | |
} | |
console.log(2) | |
function invert(obj){ | |
var result = {}; | |
for(var i in obj){ | |
let result_key = obj[i]; | |
if(!result[result_key]){ | |
result[result_key]= []; | |
} | |
result[result_key].push(i) | |
} | |
return result; | |
} | |
var ss = invert(obj); | |
console.log(ss) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment