Spocoman

03. First and Last K Numbers

Feb 5th, 2022 (edited)
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function firstAndLastKNumbers(arr) {
  2.     let index = arr.shift();
  3.     let firstEl = arr.slice(0, index);
  4.     let lastEl = arr.slice(arr.length - index)
  5.  
  6.     console.log(firstEl.join(' '));
  7.     console.log(lastEl.join(' '));
  8.  
  9. }
  10.  
Add Comment
Please, Sign In to add comment