scrimba
Note at 0:08
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:08
AboutCommentsNotes
Note at 0:08
Expand for more info
main.js
run
preview
console
function extractEachKth(nums, index) {
// write code here.
// console.log(nums);
// console.log(index);
const arrayCompare = [];
const arrayAnswer = [];
let total = 0;
let answer;

const numberDivide = index / nums.length * 10;
// console.log(numberDivide);

for(let i = 0; i < numberDivide; i++) {
arrayCompare.push(total + numberDivide);
total += numberDivide;
}
// console.log(`arrayCompare ${arrayCompare}`);

for(let i = 0; i < nums.length; i++) {

let checkForNumbers = arrayCompare.includes(nums[i]);
// console.log(checkForNumbers);
if(checkForNumbers === false) {
arrayAnswer.push(nums[i]);
}
}

console.log(arrayAnswer);
return arrayAnswer;
}

/**
* Test Suite
*/
describe('extractEachKth()', () => {
it('returns largest positive integer possible for digit count', () => {
// arrange
const nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const index = 3;

// act
const result = extractEachKth(nums, index);

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

// assert
expect(result).toEqual([1, 2, 4, 5, 7, 8, 10]);
});
});
Console
[
1
,
2
,
4
,
5
,
7
,
8
,
10
]
,
"result: "
,
[
1
,
2
,
4
,
5
,
7
,
8
,
10
]
,
/index.html
LIVE