If we have reached last state and previous state is not 1 , then check next character . If next character is ' \0' , then return true , else false
if ( curr_state === 3 && prev_state !== 1 ) return index + 1 == str . length ; index ++ ;