Check if summation of two words is equal to target word | Function to check weather summation of two words equal to target word ; Store the length of each string ; Reverse the strings A , B and C ; Stores the remainder ; Iterate in the range [ 0 , max ( L , max ( M , N ) ) ] ; Stores the integer at ith position from the right in the sum of A and B ; If i is less than L ; If i is less than M ; Update rem and curr ; If i is less than N and curr is not equal to C [ i ] - ' a ' , return " No " ; If rem is greater than 0 , return " No " ; Otherwise , return " Yes " ; Given Input ; Function Call
function isSumEqual ( A , B , C ) { let L = A . length ; let M = B . length ; let N = A . length ; A . split ( " " ) . reverse ( ) . join ( " " ) ; B . split ( " " ) . reverse ( ) . join ( " " ) ; C . split ( " " ) . reverse ( ) . join ( " " ) ; let rem = 0 ; for ( let i = 0 ; i < Math . max ( L , Math . max ( M , N ) ) ; i ++ ) { let curr = rem ; if ( i < L ) curr += A [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; if ( i < M ) curr += B [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; rem = Math . floor ( curr / 10 ) ; curr %= 10 ; if ( i < N && curr != C [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) { return " " ; } } if ( rem ) return " " ; else return " " ; } let A = " " , B = " " , C = " " ; document . write ( isSumEqual ( A , B , C ) ) ;