ReactiveX / learnrx

A series of interactive exercises for learning Microsoft's Reactive Extensions Library for Javascript.
1.4k stars 292 forks source link

Exercise #24 #106

Closed MaxKroshka closed 8 years ago

MaxKroshka commented 8 years ago

Greetings. I found a mistake in the right answer, i believe. Array.zip() by definition takes 2 arrays and a function as arguments. But when we are using the result of reduce function on an array of objects as an argument for our Array.zip() function, it will return a single object, not an array with an object in it. I was able to fix it by wrapping return result of reduce function with square brackets.

return Array.zip( video.boxarts.reduce(function(acc,curr) { if (acc.width * acc.height < curr.width * curr.height) { return [acc]; } else { return [curr]; } });

Am i correct on this or am i missing something?

Thank you.

MaxKroshka commented 8 years ago

Never mind, i figured it out. It works right, because we are using reduce() from exercise 16, not a built-in one.