counts number of ones at odd and even positions
let odd_1 = 0 , even_1 = 0 ; let n = st . length ; for ( let i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { if ( st [ i ] == ' ' ) { even_1 ++ ; } else { even_0 ++ ; } } else { if ( st [ i ] == ' ' ) { odd_1 ++ ; } else { odd_0 ++ ; } } }