-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathremoveDups.js
executable file
·62 lines (52 loc) · 1.82 KB
/
removeDups.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var array1 = [["Santa Cruz", 11],
["San Francisco", 12],
["San Jose", 13],
["Oakland", 14],
["Santa Cruz", 13],
["San Francisco", 15],
["San Jose", 16],
["Oakland", 9],
["Sacramento", 111],
];
function convertCityArr(array) {
var cities = [];
for (var i = 0; i < array.length; i++) {
var cityName = array[i].city;
cities.push(cityName)
}
return cities;
}
var unique = function (value, index, self) {
return self.indexOf(value) === index;
}
var cityList = convertCityArr(array1); //originally this line was : var cityList = convertCityArr(response);
var uniqueCities = cityList.filter(unique);
console.log(uniqueCities);
//new
//OLD
// var newList;
// newList=uniqueCitiesFromZipApi(array1);
// console.log(newList);
// function uniqueCitiesFromZipApi(zipData) {
// var uniqueCities = [[0, 0], [0, 0]];
// var element = [[0, 0], [0, 0]];
// var i =0;
// if (i < 2) {
// element[i][0] = zipData.[0][0];
// element[i][1] = zipData.[0][2];
// uniqueCities[i] = element;
// for (var i = 0; i < zipData.length; i++) {
// // if (i<2){
// // element[i][0]=zipData.zip_codes[i].city;
// // element[i][1]=zipData.zip_codes[i].distance;
// // uniqueCities[i]=element;
// if (uniqueCities[i][0] == zipData[i][0]) { i++; }
// else {
// var elem = [[0, 0], [0, 0]];
// elem[0][0] = zipData[i][0];
// elem[0][1] = zipData[i][1];
// uniqueCities[i] = element;
// }//closed the else
// //}//closed the IF
// }//closed the for
// }