Advertisement
VoidRayChe

Try to implement pop

Feb 14th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. function implementPop(arr){
  2. Array.prototype.ipop = function(){
  3. let newArr = [];
  4. for(let i = 0; i < this.length-1; i++){
  5. newArr[i] = this[i];
  6. }
  7. let popedEl = this.length-1;
  8. this = newArr;
  9. return popedEl;
  10. }
  11.  
  12. console.log(arr.ipop());
  13. console.log(arr);
  14. }
  15.  
  16. implementPop([1,2,3,4,5,6]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement