Guest User

Untitled

a guest
Feb 16th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. function testArray(array) {
  2. var copy = [...array],
  3. result = [],
  4. number = [];
  5. copy.forEach(function(el, i, ar) {
  6. let sliced = array.slice(i);
  7. console.log(sliced);
  8. // number.push(sliced[0]);
  9. number = [sliced[0]];
  10. console.log(number);
  11. for (let y = i; y <= sliced.length - 1; y++) {
  12. // console.log(sliced,'sliced array')
  13. console.log(sliced[y], 'for-loop currentValue')
  14.  
  15. // let newArray = sliced.filter(function(el,i,ar){
  16. // return el < sliced[0];
  17. // console.log(sliced[0]);
  18. // console.log(el);
  19. // console.log(ar);
  20. // if (sliced[0] > el) {
  21. // numbers.push(sliced[0]);
  22. // }
  23. // });
  24. }
  25. })
  26. // console.log(newArray);
  27. }
  28.  
  29. var arr1 = [1, 4, 3, 2]; //--> 4,3,2
  30. var arr2 = [14, 24, 3, 19, 15, 17]; //--> 24,19,17
  31. var arr3 = [41, 41, 34, 20]; //--> 41,34,24
  32. var arr4 = [27, 19, 42, 2, 13, 45, 48]; //--> 48
Add Comment
Please, Sign In to add comment