forked from alexpopdev/underscorejs-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
23 lines (19 loc) · 804 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var _ = require("underscore");
var clientRetriever = require("./clientRetriever");
var transformations = require("./transformations");
var oldestClients = clientRetriever.getOldestClients(5);
var bestClients = clientRetriever.getBestClients(5);
var clients = clientRetriever.getClients();
console.log("There are " + clients.length + " clients.");
var getContactsOutput = function(clients) {
var outputText = "";
_.forEach(clients, function(client, index) {
if (index > 0) {
outputText += ", ";
}
outputText += transformations.getContactNameIdAndType(client);
});
return outputText;
};
console.log("Top 5 oldest clients with name, id and type: " + getContactsOutput(oldestClients));
console.log("Top 5 best clients with name, id and type: " + getContactsOutput(bestClients));