scrimba
Note at 1:17
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

AboutCommentsNotes
Note at 1:17
Expand for more info
main.js
run
preview
console
function avoidObstacles(nums) {
// write code here.

let z = nums.sort() //sort the arr
let x = 2 // 1 wont work
while (true) {
let y = 0
if (z.every((y) => y % x != 0)) {
return x
}
x += 1
}
}





/**
* 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
"result: "
,
4
,
/index.html
LIVE