Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function highest(arr) {
  2.     if (arr.length == 1) {
  3.         return arr[0];
  4.     } else if (arr[arr.length - 1] > arr[arr.length - 2]) {
  5.         arr[arr.length - 2] = arr[arr.length - 1];
  6.         arr.pop();
  7.         console.log(arr);
  8.         this.highest(arr);
  9.            
  10.     } else {
  11.         arr.pop();
  12.         console.log(arr);
  13.         this.highest(arr);
  14.     }  
  15. }
  16. console.log(highest([1, 3, 4, 5, 6, 8]));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement