scrimba
Note at 0:39
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 0:39
AboutCommentsNotes
Note at 0:39
Expand for more info
main.js
run
preview
console
function avoidObstacles(nums) {
// find the smallest number that is not a common denominator of the other numbers
let avoids = false;
let jumperNum = 0;
while (!avoids) {
jumperNum++;
avoids = nums.every(num => num % jumperNum !== 0);
}
return jumperNum;
}

/**
* Test Suite
*/
describe('avoidObstacles()', () => {
it('returns minimal number of jumps in between numbers', () => {
// arrange
const nums = [5, 3, 6, 7, 9];

// act
const result = avoidObstacles(nums);

// log
console.log("result: ", result);

// assert
expect(result).toBe(4);
});
});
Console
"1 is divisible by at least one number; incrementing by 1"
,
"2 is divisible by at least one number; incrementing by 1"
,
"3 is divisible by at least one number; incrementing by 1"
,
"4 is divisible by at least one number; incrementing by 1"
,
"result: "
,
4
,
/index.html
LIVE