Advertisement
-Annie-

PrintEveryNthElementOFArray

Jun 2nd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let step = input.pop();
  3.     step = Number.parseInt(step);
  4.     let arr = [];
  5.  
  6.     for(let i = 0; i <= input.length ; i+=step) {
  7.         arr.push(input[i]);
  8.     }
  9.    
  10.     console.log(arr.join('\n'));
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement