curriculum/challenges/english/blocks/daily-coding-challenges-javascript/68cae5b538ff798bbd4da007.md
Given an integer representing the number of pairs of socks you started with, and another integer representing how many wash cycles you have gone through, return the number of complete pairs of socks you currently have using the following constraints:
sockPairs(2, 5) should return 1.
assert.equal(sockPairs(2, 5), 1);
sockPairs(1, 2) should return 0.
assert.equal(sockPairs(1, 2), 0);
sockPairs(5, 11) should return 4.
assert.equal(sockPairs(5, 11), 4);
sockPairs(6, 25) should return 3.
assert.equal(sockPairs(6, 25), 3);
sockPairs(1, 8) should return 0.
assert.equal(sockPairs(1, 8), 0);
function sockPairs(pairs, cycles) {
return pairs;
}
function sockPairs(pairs, cycles) {
let socks = pairs * 2;
for (let i = 1; i <= cycles; i++) {
if (i % 2 === 0) socks -= 1;
if (i % 3 === 0) socks += 1;
if (i % 5 === 0) socks -= 1;
if (i % 10 === 0) socks += 2;
if (socks < 0) socks = 0;
}
return Math.floor(socks / 2);
}