Traversing the String
for ( let i = 0 ; i < num . length ; i ++ ) if ( i % 2 == 0 ) sumOdd = sumOdd + ( num [ i ] - ' ' ) ; else sumEven = sumEven + ( num [ i ] - ' ' ) ; document . write ( " " + sumOdd + " " ) ; document . write ( " " + sumEven + " " ) ; }