diff --git a/javascript/src/lib/factors.js b/javascript/src/lib/factors.js index a4840344..6a9314bb 100644 --- a/javascript/src/lib/factors.js +++ b/javascript/src/lib/factors.js @@ -4,12 +4,12 @@ * @yield {number} */ function* properDivisors(num) { - factors = [...primes.primeFactors(num)]; + const factors = [...primes.primeFactors(num)]; const seen = new Set(); yield 1; for (let x = 1; x < factors.length; x++) { for (const combo of iters.combinations(factors, x)) { - ret = combo.reduce((a, x) => a * x, 1); + const ret = combo.reduce((a, x) => a * x, 1); if (!seen.has(ret)) { yield ret; seen.add(ret); diff --git a/javascript/src/lib/iters.js b/javascript/src/lib/iters.js index 497b3712..fee81b16 100644 --- a/javascript/src/lib/iters.js +++ b/javascript/src/lib/iters.js @@ -12,7 +12,7 @@ exports.combinations = function* combinations(iterable, r) { if (r > n) { return; } - indices = [...Array(r).keys()]; + const indices = [...Array(r).keys()]; yield Array.from(indices.map((i) => pool[i])); while (true) { @@ -49,7 +49,7 @@ exports.combinationsWithReplacement = function* combinationsWithReplacement(iter if (r > n) { return; } - indices = [...Array(r).keys()]; + const indices = [...Array(r).keys()]; yield Array.from(indices.map((i) => pool[i])); while (true) { diff --git a/javascript/src/lib/utils.js b/javascript/src/lib/utils.js index a66e044b..bcd64a02 100644 --- a/javascript/src/lib/utils.js +++ b/javascript/src/lib/utils.js @@ -49,12 +49,12 @@ exports.get_answer = function(n) { continue; } if (type === 'str') { - if (value.length !== parseInt(size)) { + if (value.length !== Number(size)) { throw new Error('string length does not match'); } return value; } - return parseInt(value); + return Number(value); } throw new Error('Answer not found'); };