Check if given string satisfies the following conditions | Function to check if given string satisfies the given conditions ; Dimensions ; Left diagonal ; Right diagonal ; Conditions not satisfied ; Prlet Yes ; Given String ; Function call
function isValid ( s ) { let n = Math . sqrt ( s . length ) ; let check = s [ 0 ] ; for ( let i = 0 ; i < n ; i ++ ) { let x = i , y = i ; while ( x >= 0 && y < n ) { if ( s [ ( n * x ) + y ] != check || s [ ( n * y ) + x ] != check ) { document . write ( " " ) ; return ; } x -- ; y ++ ; } } document . write ( " " ) ; } let str = " " ; isValid ( str ) ;