Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to check array is sorted or not in javascript

function isArraySorted(arr) {
    for (let i = 0; i < arr.length; i++) {
      if (arr[i + 1] && arr[i + 1] > arr[i]) {
        continue;
      } else if (arr[i + 1] && arr[i + 1] < arr[i]) {
        return false;
      }
    }
    return true;
  }
Comment

PREVIOUS NEXT
Code Example
Javascript :: Syntax for creating a specific version of react app 
Javascript :: javascript float 2 decimal 
Javascript :: telegraf js sendmessage 
Javascript :: calculate distance between two coordinates formula javascript 
Javascript :: jquery radio button change 
Javascript :: discord.js message on member add 
Javascript :: js isprome 
Javascript :: js on edge files 
Javascript :: javascript eliminar items repetidos 
Javascript :: adonisjs hook befor save 
Javascript :: useevent hook in react18 
Javascript :: convert responsetext to json python 
Javascript :: sort an array by the laster letter of element javascript 
Javascript :: discord.js join voice channel 
Javascript :: socket io https 
Javascript :: check if a string is alphanumeric 
Javascript :: larger text console javascript 
Javascript :: jquery get link href value 
Javascript :: how to get a value using jquery 
Javascript :: how to push the get variables without page reloading in Jquery 
Javascript :: else if shopify liquid 
Javascript :: commas for thousands js 
Javascript :: localstorage setitem javascript 
Javascript :: check if base64 
Javascript :: iscolor 
Javascript :: event on input or keydown or on paste value or on change jquery 
Javascript :: jspdf addimage 
Javascript :: convert milliseconds to seconds js 
Javascript :: checkbox is checked jquery 
Javascript :: protractor screen size 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =