scrimba
Note at 0:22
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:22
by
AboutCommentsNotes
Note at 0:22
by
Expand for more info
main.js
run
preview
console
const extractEachKth=(nums, index)=>nums.filter((item,index2)=>(index2 +1)%index!==0)



/**
* 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]);
});

it('returns largest positive integer possible for digit count', () => {
// arrange
const nums = [10, 9, 8, 7, 6];
const index = 3;

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

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

// assert
expect(result).toEqual([10, 9, 7, 6]);
});

it('returns largest positive integer possible for digit count', () => {
// arrange
const nums = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"];
const index = 3;

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

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

// assert
expect(result).toEqual(["a", "b", "d", "e", "g", "h", "j"]);
});
});

Console
"result: "
,
[
10
,
9
,
7
,
6
]
,
"result: "
,
[
1
,
2
,
4
,
5
,
7
,
8
,
10
]
,
"result: "
,
[
"a"
,
"b"
,
"d"
,
"e"
,
"g"
,
"h"
,
"j"
]
,
/index.html
LIVE