Find letter 's position in Alphabet using Bit operation | JavaScript implementation of the approach ; Function to calculate the position of characters ; Performing AND operation with number 31 ; Driver code
const NUM = 31 ; function positions ( str , n ) { for ( i = 0 ; i < n ; i ++ ) { document . write ( ( str [ i ] . charCodeAt ( 0 ) & NUM ) + " " ) ; } } var str = " " ; var n = str . length ; positions ( str , n ) ;