1const every_nth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1);
2console.log(every_nth([1, 2, 3, 4, 5, 6], 1));
3console.log(every_nth([1, 2, 3, 4, 5, 6], 2));
4console.log(every_nth([1, 2, 3, 4, 5, 6], 3));
5console.log(every_nth([1, 2, 3, 4, 5, 6], 4));
6
7// OUTPUT
8
9[1,2,3,4,5,6]
10[2,4,6]
11[3,6]
12[4]