scrimba
Note at 0:33
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:33
AboutCommentsNotes
Note at 0:33
Expand for more info
main.js
run
preview
console
function extractEachKth(arr, element) {     
return arr.filter((value, index) => (index + 1) % element !== 0)
}

/*or:
function extractEachKth (arr, element) {

function division (value, index) {
return (index + 1) % element !== 0
}
const result = arr.filter(division)
return result
}
*/


/**
* Test Suite
*/
describe('extractEachKth()', () => {
it('returns largest positive integer possible for digit count', () => {
// arrange
const nums = [1, 2, 13, 4, 5, 21, 7, 8, 84, 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
"result: "
,
[
1
,
2
,
4
,
5
,
7
,
8
,
10
]
,
/index.html
LIVE