Toggle case of a string using Bitwise Operators | program to get toggle case of a string ; tOGGLE cASE = swaps CAPS to lower case and lower case to CAPS ; Bitwise EXOR with 32 ; Driver program
x = 32 ; function toggleCase ( a ) { for ( i = 0 ; i < a . length ; i ++ ) { a [ i ] = String . fromCharCode ( a [ i ] . charCodeAt ( 0 ) ^ 32 ) ; } return a . join ( " " ) ; ; } var str = " " ; document . write ( " " ) ; str = toggleCase ( str . split ( ' ' ) ) ; document . write ( str ) ; document . write ( " " ) ; str = toggleCase ( str . split ( ' ' ) ) ; document . write ( str ) ;