Set states according to the input characters in the string and the rule defined in the description . If current character is [ A - Z ] . Set current state as 0.
if ( str [ index ] . charCodeAt ( 0 ) >= " " . charCodeAt ( 0 ) && str [ index ] . charCodeAt ( 0 ) <= " " . charCodeAt ( 0 ) ) curr_state = 0 ;