Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
var input={
  value:{'btc-usd' : 2640, 'ltc-usd': 40},
  amount:{'btc-usd': 2.533, 'ltc-usd': 10.42},
  name:{"btc-usd":"Bitcoin","ltc-usd":"Litecoin"}
};
var hash={};
for(key in input){
   var values=input[key];
   for(id in values){
      if(!hash[id]) hash[id]={};
      hash[id][key]=values[id];
    }
}
var output=[];
for(id in hash){
  hash[id].id=id;
  output.push(hash[id]);
}
console.log("input",input,"hash",hash,"output",output);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers