mrdavidlaing / javascript-koans

Koans to learn Javascript
MIT License
2.41k stars 3.51k forks source link

flatten not working for products array in AboutApplyingWhatWeHaveLearnt.js #66

Open c4p3n opened 8 years ago

c4p3n commented 8 years ago

In the very last challenge in AboutApplyingWhatWeHaveLearnt.js, it("should count the ingredient occurrence (imperative)", I tried replacing the FILL_MEIN placeholder with `(products).flatten()` to see what the effect would be. The output to the browser in KoansRunner.html is as follows:

[ { name : 'Sonoma', ingredients : [ 'artichoke', 'sundried tomatoes', 'mushrooms' ], containsNuts : false, beget : Function }, { name : 'Pizza Primavera', ingredients : [ 'roma', 'sundried tomatoes', 'goats cheese', 'rosemary' ], containsNuts : false, beget : Function }, { name : 'South Of The Border', ingredients : [ 'black beans', 'jalapenos', 'mushrooms' ], containsNuts : false, beget : Function }, { name : 'Blue Moon', ingredients : [ 'blue cheese', 'garlic', 'walnuts' ], containsNuts : true, beget : Function }, { name : 'Taste Of Athens', ingredients : [ 'spinach', 'kalamata olives', 'sesame seeds' ], containsNuts : true, beget : Function } ]

It appears to me that the flatten function isn't actually doing anything to the products array. Am I misusing the function or is there a problem?

meaton-potatoes commented 8 years ago

I had that issue, as well, with both flatten() and chain()

SherylHohman commented 8 years ago

See