Creating new strings by exchanging the first half of a and b . Please refer below for details of substring . https : www . geeksforgeeks . org / java - lang - string - substring - java /
var c = a . substring ( 0 , la / 2 ) + b . substring ( lb / 2 , lb ) ; var d = b . substring ( 0 , lb / 2 ) + a . substring ( la / 2 , la ) ; document . write ( c + " " + " " + d ) ; }