traverse the command array
for ( let i = 0 ; i < n ; i ++ ) { if ( command [ i ] == ' ' ) cup ++ ; else if ( command [ i ] == ' ' ) cdown ++ ; else if ( command [ i ] == ' ' ) cleft ++ ; else if ( command [ i ] == ' ' ) cright ++ ; }