You are viewing a single comment's thread. Return to all comments →
Javascript solution:-
function countApplesAndOranges(s, t, a, b, apples, oranges) { const isFallingOnHouse = (startPoint) => ((prev, frute) => { const position = startPoint + frute; if (position >= s & position <= t) prev++; return prev; }) const appleFallsOnHouse = apples.reduce(isFallingOnHouse(a), 0) console.log(appleFallsOnHouse); const orangesFallsOnHouse = oranges.reduce(isFallingOnHouse(b), 0) console.log(orangesFallsOnHouse); }
Seems like cookies are disabled on this browser, please enable them to open this website
Apple and Orange
You are viewing a single comment's thread. Return to all comments →
Javascript solution:-