text: Function to find the final direction
code: function findDirection ( s ) { let count = 0 ; let d = " " ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( s [ 0 ] == ' ' ) return null ; if ( s [ i ] == ' ' ) count -- ; else { if ( s [ i ] == ' ' ) count ++ ; } }