Skip to content

Commit bc32a64

Browse files
committed
fixed
1 parent 0c88abc commit bc32a64

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

koans/AboutApplyingWhatWeHaveLearnt.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ var hasMushroomsOrNuts = function (x){
107107
var ingredientCount = { "{ingredient name}": 0 };
108108

109109
/* chain() together map(), flatten() and reduce() */
110-
_.chain(products)
111-
.map(function(name){return name.ingredients();})
112-
.flatten()
113-
.reduce(function(counts, ingredient){
114-
counts[ingredient] = (counts[ingredient] || 0) + 1;
115-
return counts;
116-
}, {})
117-
.value();
110+
111+
_.chain(products).map(function(product){
112+
return product.ingredients;
113+
}).flatten().each(function(ingredient){
114+
if (!ingredientCount[ingredient]){
115+
ingredientCount[ingredient] = 0;
116+
}
117+
ingredientCount[ingredient] += 1;
118+
});
118119

119120
expect(ingredientCount['mushrooms']).toBe(2);
120121
});

koans/AboutFunctions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ describe("About Functions", function() {
106106
expect(multiply.toString()).toBe('function (a, b) {
107107
//An internal comment
108108
return a * b;
109-
}');
110-
});
109+
};');
110+
});
111111
});

0 commit comments

Comments
 (0)