Check if the number is balanced | Function to check whether N is Balanced Number or not ; Calculating the Leftsum and rightSum simultaneously ; Typecasting each character to integer and adding the digit to respective sums ; Driver Code ; Function call
function BalancedNumber ( s ) { let Leftsum = 0 ; let Rightsum = 0 ; for ( let i = 0 ; i < s . length / 2 ; i ++ ) { Leftsum += ( s [ i ] - ' ' ) ; Rightsum += ( s [ s . length - 1 - i ] - ' ' ) ; } if ( Leftsum == Rightsum ) document . write ( " " ) ; else document . write ( " " ) ; } let s = " " ; BalancedNumber ( s ) ;