Check if the characters of a given string are in alphabetical order | Function that checks whether the string is in alphabetical order or not ; if element at index ' i ' is less than the element at index ' i - 1' then the string is not sorted ; Driver code ; check whether the string is in alphabetical order or not
function isAlphabaticOrder ( s ) { let n = s . length ; for ( let i = 1 ; i < n ; i ++ ) { if ( s [ i ] < s [ i - 1 ] ) return false ; } return true ; } let s = " " ; if ( isAlphabaticOrder ( s ) ) document . write ( " " ) ; else document . write ( " " ) ;