Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function highest(arr) {
- if (arr.length == 1) {
- return arr[0];
- } else if (arr[arr.length - 1] > arr[arr.length - 2]) {
- arr[arr.length - 2] = arr[arr.length - 1];
- arr.pop();
- console.log(arr);
- this.highest(arr);
- } else {
- arr.pop();
- console.log(arr);
- this.highest(arr);
- }
- }
- console.log(highest([1, 3, 4, 5, 6, 8]));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement