File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 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-
81function 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+ } ) ;
You can’t perform that action at this time.
0 commit comments