Advertisement
Liliana797979

print Every Nth Element - js advanced

Oct 16th, 2021
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function printEveryNthElement(input) {
  2.     let n = input[input.length - 1];
  3.     input.pop();
  4.  
  5.     for(let i = 0; i <= input.length; i+=n){
  6.         console.log(input[i]);
  7.     }
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement