Tell us what’s happening:
I’ve confirmed in my own browser that the required values are output by the function, but pressing the “Run the Tests” button does nothing (doesn’t even result in any error messages).
I’m using EC6 things like the function arrow and let/const, but that should be OK, shouldn’t it?
Your code so far
// Intermediate Algorithm Scripting: Smallest Common Multiple
function smallestCommons(arr) {
// Store values.
arr = [...arr].sort((a,b) => a > b);
// Generate array of divisors.
let divs = [];
for (let i = arr[0]; i <= arr[1]; i++)
divs.push(i);
// Determine highest possible multiple = all numbers multipled together.
const hpm = divs.reduce((a, b) => a * b);
// Test for whether a number is divisible by all divisors.
function divisibleByAll(div) {
var ok = true;
for (let c = 0; c < divs.length; c++) {
if (div % divs[c] != 0) {
ok = false;
break;
}
}
if (ok) {
return true;
} else {
return false;
}
}
// Iterate through nums from the largest divisor through the highest possible.
for (let i = arr[1]; i <= hpm; i += arr[1])
if (divisibleByAll(i)) return i;
}
smallestCommons([1,5]);
Here are some browser JS errors that the FCC libraries throw:
TypeError: "unknown: o is undefined"
gethttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:32:10856hhttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:49:1470ihttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:21:4737rhttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:49:11676ohttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:48:1367ihttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:48:1090ahttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:48:1758visitQueuehttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:47:29396visitMultiplehttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:47:28845visithttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:47:29798nodehttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:31:17426ahttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:48:1903 transformers.js:85:6
TypeError: "unknown: o is undefined"
gethttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:32:10856hhttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:49:1470ihttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:21:4737rhttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:49:11676ohttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:48:1367ihttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:48:1090ahttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:48:1758visitQueuehttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:47:29396visitMultiplehttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:47:28845visithttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:47:29798nodehttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:31:17426ahttps://learn.freecodecamp.org/commons-b48a099b457b77b5ddc8.js:48:1903 transformers.js:85:6 ```
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/smallest-common-multiple