Created
December 19, 2017 17:54
-
-
Save mariusom/d492cd2a4b838b77869a4e985be47d8d to your computer and use it in GitHub Desktop.
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 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