Skip to content

Instantly share code, notes, and snippets.

@mariusom
Created December 19, 2017 17:54
Show Gist options
  • Save mariusom/d492cd2a4b838b77869a4e985be47d8d to your computer and use it in GitHub Desktop.
Save mariusom/d492cd2a4b838b77869a4e985be47d8d to your computer and use it in GitHub Desktop.
var output = [];
//var dataSource = app.models.Employee.newQuery().run();
var dataSource = [
{
timestamp: "2017-09-12 13:49",
fullname: "John",
emailAddress: "[email protected]"
//....
},
{
timestamp: "2017-06-12 13:49",
fullname: "John",
emailAddress: "[email protected]"
},
{
timestamp: "2017-09-12 13:49",
fullname: "Johhyn",
emailAddress: "[email protected]"
}
];
for (var i = 0; i < dataSource.length; i++) {
var employee = dataSource[i];
var foundOutputEmployeeIndex = null;
for (var j = 0; j < output.length; j++) {
if (
output[j].emailAddress === employee.emailAddress &&
foundEmp.timestamp < employee.timestmap
) {
output[j] = employee;
}
}
if (foundOutputEmployeeIndex != null) {
output.push(employee);
}
}
console.log(output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment