javascript array get nth element
//#Source https://bit.ly/2neWfJ2
const every_nth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1);
console.log(every_nth([1, 2, 3, 4, 5, 6], 1));
console.log(every_nth([1, 2, 3, 4, 5, 6], 2));
console.log(every_nth([1, 2, 3, 4, 5, 6], 3));
console.log(every_nth([1, 2, 3, 4, 5, 6], 4));
Also in JavaScript:
- nodejs json data serving
- javascript get file extension from string
- moment check valid date
- how to freeze js object
- javascript loop through object array
- js detect mobile
- json-server localhost
- color text react native
- getelementbyclass
- javascript date get day of week abbreviation
- convert string to datetime javascript
- how to run resize event only on client side angular
- how to clear terminal in vs code
- jquery convert a string to an array
- rounding up a number so that it is divisible by 5 javascript
- .map function
- js remove json value duplicates
- new features of angular 11
- get length of array
- return only specific attributes when making query mongoose
- p5.js script tag
- react export
- leap year in javascript
- live background react