Skip to content

Commit 0570903

Browse files
committed
move Array.contains to end
1 parent 21f2aab commit 0570903

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/recommendationEngine.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
Object.defineProperty(Array.prototype, 'contains', {
2-
value: function (primitive) {
3-
return this.indexOf(primitive) !== -1 // <- Nobody wants to read that!
4-
},
5-
enumerable: false // Looking at object's keys will NOT include this property.
6-
});
7-
81
function u (list1, list2) {
92
return list1.concat(list2).reduce(function(union, item){
103
return list1.contains(item) && list2.contains(item) && !union.contains(item) ? union.concat(item) : union
@@ -100,3 +93,11 @@ function recommendationsFor(user, users) {
10093
// return array of itemIds ordered by greatest probabilityOfLike first
10194
return recommendations
10295
}
96+
97+
// You're welcome to use this but you don't have to: [1,2,3].contains(2) -> true
98+
Object.defineProperty(Array.prototype, 'contains', {
99+
value: function (primitive) {
100+
return this.indexOf(primitive) !== -1 // <- Nobody wants to read that!
101+
},
102+
enumerable: false // Looking at object's keys will NOT include this property.
103+
});

0 commit comments

Comments
 (0)