function to return integer value of i - th character in the string
function charVal ( s , i ) { if ( s . charAt ( i ) == ' ' ) { return 0 ; } else if ( s . charAt ( i ) == ' ' ) { return 1 ; } else { return 2 ; } }