Skip to content

Instantly share code, notes, and snippets.

@mariusom
Created December 19, 2017 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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: "john@doe.com"
//....
},
{
timestamp: "2017-06-12 13:49",
fullname: "John",
emailAddress: "john@doe.com"
},
{
timestamp: "2017-09-12 13:49",
fullname: "Johhyn",
emailAddress: "john@dosse.com"
}
];
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