Combining all the thee parts of the answer
let answer = prefix + midPal + suffix ; return answer ; } function reverse ( input ) { let a = input . split ( " " ) ; let l , r = a . length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { let temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return ( a ) . join ( " " ) ; }