You are viewing a single comment's thread. Return to all comments →
I also used this method. As a beginner, I think it is easier to understand then those oneliner.
function countApplesAndOranges(s, t, a, b, apples, oranges) { let totalApples = 0; let totalOranges = 0; for (let i = 0; i <= apples.length; i++) { if (a + apples[i] >= s && a + apples[i] <= t) { totalApples += 1; } } for (let i = 0; i <= oranges.length; i++) { if (b + oranges[i] >= s && b + oranges[i] <= t) { totalOranges += 1; } } console.log(totalApples); console.log(totalOranges); }
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 →
I also used this method. As a beginner, I think it is easier to understand then those oneliner.