SHARE
TWEET

Untitled

a guest Aug 25th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function isSortedAndHow(array) {
  2.  if(array.sort((a,b) => a-b)){
  3.    return "yes, ascending";
  4.    } else if (array.sort((a,b) => b-a)){
  5.    return "yes, descending";
  6.    } else {
  7.    return "no";
  8.    }
  9.   }
  10.    for(var i = 0; i < array.length; i++){
  11.     if(array[0] < array[1] && array[0] < array[2]){
  12.     return "yes, ascending";
  13.     } else if(array[0] > array[1] && array[0] > array[2]){
  14.     return "yes, descending";
  15.     } else {
  16.     return "no";
  17.    }
  18.   }
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top