Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//jashkenas.github.io/underscore/underscore-min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
  </head>
<body>
</body>
</html>
 
var response = [
  {
    Name: "Name1",
    Place: {
      state: "New York",
    },
    Alive: false
  }, {
    Name: "Name2",
    Place: {
      state: "New York",
    },
    Alive: true
  }, {
    Name: "Name3",
    Place: {
      state: "New York",
    },
    Alive: true
  }, {
    Name: "Name4",
    Place: {
      state: "New York",
    },
    Alive: true
  }, {
    Name: "Name5",
    Place: {
      state: "London",
    },
    Alive: false
  }, {
    Name: "Name6",
    Place: {
      state: "London",
    },
    Alive: true    
  }
];
var collapsed = _.reduce(response, function(memo, item) {
  if ( ! memo[item.Place.state]) {
    memo[item.Place.state] = 0;
  }
  memo[item.Place.state]++;
  return memo;
}, {});
console.log(collapsed);
var filtered = _.filter(response, function(item) {
  return item.Place.state === "New York";
});
console.log(filtered);
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers