Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function printNthElementFromArray(arr, number) {
- let resultArr = [];
- for (let i = 0; i < arr.length; i+=number) {
- resultArr.push(arr[i]);
- }
- return resultArr;
- }
- // printNthElementFromArray(['5',
- // '20',
- // '31',
- // '4',
- // '20'
- // ],
- // 2
- // );
- // printNthElementFromArray(['dsa',
- // 'asd',
- // 'test',
- // 'tset'],
- // 2
- // );
- // printNthElementFromArray(['1',
- // '2',
- // '3',
- // '4',
- // '5'],
- // 6
- // );
Add Comment
Please, Sign In to add comment