Prime String | Function that checks if sum is prime or not ; Corner cases ; This is checked so that we can skip middle five numbers in below loop ; Driver code
function isPrimeString ( str ) { let len = str . length , n = 0 ; for ( let i = 0 ; i < len ; i ++ ) { n += str [ i ] . charCodeAt ( ) ; } if ( n <= 1 ) { return false ; } if ( n <= 3 ) { return true ; } if ( n % 2 == 0 n % 3 == 0 ) { return false ; } for ( let i = 5 ; i * i <= n ; i = i + 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) { return false ; } } return true ; } let str = " " ; if ( isPrimeString ( str ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }