Check if string is right to left diagonal or not | Function to check if the given string is right to left diagonal or not ; Iterate over string ; If character is not same as the first character then return false ; Given String str ; Function call
function is_rtol ( s ) { let tmp = ( Math . sqrt ( s . length ) ) - 1 ; let first = s [ tmp ] ; for ( let pos = tmp ; pos < s . length - 1 ; pos += tmp ) { if ( s [ pos ] != first ) { return false ; } } return true ; } let str = " " ; if ( is_rtol ( str ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }