Print all the non | Function to print all the non - repeating words from the two given sentences ; Concatenate the two Strings into one ; Iterating over the whole concatenated String ; Searching for the word in A . If while searching , we reach the end of the String , then the word is not present in the String ; Initialise word for the next iteration ; Driver code
function removeRepeating ( s1 , s2 ) { let s3 = s1 + " " + s2 + " " ; let words = " " ; let i = 0 ; let temp = s3 . split ( " " ) for ( let x = 0 ; x < temp . length ; x ++ ) { if ( temp [ x ] == ' ' ) { if ( ! s1 . includes ( words ) || ! s2 . includes ( words ) ) document . write ( words ) ; words = " " ; } else { words = words + temp [ x ] ; } } } let s1 = " " ; let s2 = " " ; removeRepeating ( s1 , s2 ) ;